-
Notifications
You must be signed in to change notification settings - Fork 169
Added a /Tags endpoint to query all tags #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new GET endpoint /tags/ to retrieve all tags from the Obsidian vault with their usage counts, enabling downstream applications like mcp-obsidian to access the complete tag inventory for intelligent tag suggestions.
Key changes:
- Implemented
/tags/GET endpoint with bearer token authentication - Added test coverage for the new endpoint (happy path and unauthorized access)
- Included comprehensive Postman collection, Makefile, and AI assistant documentation
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/requestHandler.ts | Added tagsGet() method and registered /tags/ route |
| src/requestHandler.test.ts | Added tests for the tags endpoint (authenticated and unauthorized cases) |
| mocks/obsidian.ts | Added getTags() mock method to MetadataCache |
| versions.json | Added version 3.2.1 mapping to Obsidian 0.12.0 |
| package.json | Bumped version to 3.2.1 |
| manifest.json | Bumped version to 3.2.1 |
| package-lock.json | Updated version and dependency peer flags |
| Obsidian_Local_REST_API.postman_collection.json | New comprehensive Postman collection including tags endpoint |
| Makefile | New development workflow automation file |
| CLAUDE.md | New AI assistant guidance documentation |
| .gitignore | Added .claude directory to ignore list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async tagsGet(req: express.Request, res: express.Response): Promise<void> { | ||
| const allTags = (this.app.metadataCache as any).getTags(); | ||
|
|
||
| res.json({ | ||
| tags: allTags, | ||
| }); | ||
| } |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenAPI documentation needs to be updated to include the new /tags/ endpoint. The documentation is generated from docs/src/openapi.jsonnet, and this endpoint should be added there following the pattern of similar endpoints like /commands/.
Example structure to add:
'/tags/': {
get: {
summary: 'Get all tags',
description: 'Retrieves all tags from the vault with their usage counts',
tags: ['Tags'],
responses: {
'200': {
description: 'Tags retrieved successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
tags: {
type: 'object',
additionalProperties: {
type: 'number'
}
}
}
}
}
}
}
}
}
}
coddingtonbear
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! I think this is totally something that could be useful to folks; so I'm up for merging this, but there are a few things I'll need from you first:
- I added a few comments in here about things that either shouldn't be in a PR or should be in a separate one.
- Leave the version incrementing to me. These changes will probably end up bundled into a larger release, and the version number you suspect I'll increment to may not match what it actually turns out to be (e.g. if your changes are bundled with a backward-incompatible change, the major version number would be incremented, etc.).
- I'll need to ask you to update the docs to include this new API endpoint. See the
docsfolder for a rough idea about what you'll need to do for that.
Once you've had a chance to look into all of this, let me know and I'll have another look! Thanks again for the patch!
| @@ -0,0 +1,455 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, I won't be able to find the time to verify this collection -- could you separate this out into its own PR so this postman collection and your actual change request can be considered separately?
| @@ -1,6 +1,6 @@ | |||
| { | |||
| "name": "obsidian-local-rest-api", | |||
| "version": "3.2.0", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove these version number bumps? I handle those as part of the release process and will increment the version number following semver guidelines depending on what kinds of changes end up in that release.
Also, by the way, since this is a new feature instead of a bugfix this would be a minor version bump instead of a patch (i.e. 3.2.0 -> 3.3.0 instead of 3.2.0 -> 3.2.1).
| "3.0.4": "0.12.0", | ||
| "3.0.5": "0.12.0", | ||
| "3.1.0": "0.12.0", | ||
| "3.2.0": "0.12.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& of course this should be removed, too, since I'll generate this as part of the release.
| @@ -0,0 +1,132 @@ | |||
| # CLAUDE.md | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the CLAUDE.md file was added accidentally. It looks like a temporary artifact produced by the Claude AI assistant, not something intended for the repo. Can you remove it from this PR?
| } | ||
|
|
||
| async tagsGet(req: express.Request, res: express.Response): Promise<void> { | ||
| const allTags = (this.app.metadataCache as any).getTags(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you've had to cast this as any to make .getTags accessible, it makes me think that maybe the obsidian types are out-of-date?
That being said, I don't see them documented in the official types -- are you sure this exists and is a public interface?
| @@ -0,0 +1,60 @@ | |||
| .PHONY: help build install dev clean | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this might be helpful for you, but I'm not sure I want to take on maintenance of this particular part of this PR and instead would rather we keep all scripts in package.json. Could I trouble you into removing this?
I know that it seems harmless to add unrelated things in a single PR, but unfortunately every bit of code that's added is a liability that will require future maintenance, support, and updates as time goes on, and I really need to be careful about what I agree to maintain going forward.
Summary
Added a new endpoint to retrieve all tags from the vault, enabling downstream applications to query the complete tag collection.
Motivation
This new endpoint allows the MCP Obsidian integration to be extended with access to the full tag inventory for intelligent tag suggestions when creating notes.
Changes
Impact
This endpoint will enable
mcp-obsidianto be easily extended to query available tagsThe feature is particularly valuable for AI-assisted note creation workflows where tag suggestions improve organization and discoverability.