feat: Include OpenAPI tags in the tool interface#59
feat: Include OpenAPI tags in the tool interface#59Pldesch wants to merge 1 commit intoharsha-iiiv:mainfrom
Conversation
…e and object creation.
📝 WalkthroughWalkthroughThe changes introduce a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/types/index.ts (1)
66-66: Add a brief field doc fortagsfor consistency.Line 66 introduces a useful field, but it’s the only property in
McpToolDefinitionwithout an inline description. A short JSDoc here will keep the interface self-documenting for downstream consumers.Suggested tweak
- tags?: string[]; + /** OpenAPI operation tags used for grouping/filtering */ + tags?: string[];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/types/index.ts` at line 66, Add a short JSDoc comment for the tags property on the McpToolDefinition interface: document that `tags?: string[]` is an optional list of short keyword labels or categories used to classify or search the tool. Update the comment directly above the `tags?: string[]` declaration in the McpToolDefinition block so it matches the style/format of the other inline descriptions in the file.src/parser/extract-tools.ts (1)
105-105: Copyoperation.tagsdefensively to avoid shared mutable state.At Line 105, assigning the array directly keeps a shared reference to the source OpenAPI object. Cloning prevents accidental cross-mutation if either side is modified later.
Proposed change
- tags: operation.tags, + tags: operation.tags ? [...operation.tags] : undefined,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/parser/extract-tools.ts` at line 105, The assignment "tags: operation.tags" creates a shared reference to the source OpenAPI array; change it to create a defensive copy (e.g., set tags to a cloned array) so mutations won't affect the original. Update the code that builds the object (the line assigning tags in src/parser/extract-tools.ts where "tags: operation.tags" appears) to use a safe clone (e.g., spread or slice) and preserve null/undefined behavior (e.g., tags: operation.tags ? [...operation.tags] : operation.tags).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/parser/extract-tools.ts`:
- Line 105: The assignment "tags: operation.tags" creates a shared reference to
the source OpenAPI array; change it to create a defensive copy (e.g., set tags
to a cloned array) so mutations won't affect the original. Update the code that
builds the object (the line assigning tags in src/parser/extract-tools.ts where
"tags: operation.tags" appears) to use a safe clone (e.g., spread or slice) and
preserve null/undefined behavior (e.g., tags: operation.tags ?
[...operation.tags] : operation.tags).
In `@src/types/index.ts`:
- Line 66: Add a short JSDoc comment for the tags property on the
McpToolDefinition interface: document that `tags?: string[]` is an optional list
of short keyword labels or categories used to classify or search the tool.
Update the comment directly above the `tags?: string[]` declaration in the
McpToolDefinition block so it matches the style/format of the other inline
descriptions in the file.
|
@harsha-iiiv Hi, I made this quick pr because we intend to use this package for some project in my company but we would need to have access to the tags from our OpenAPI model to ease the filtering. Do you think we could have this merged soon ? Thanks |
Add openapi tags into the MCP Tool description to allow more fine-grained control for filtering
Summary by CodeRabbit