Skip to content

feat: Include OpenAPI tags in the tool interface#59

Open
Pldesch wants to merge 1 commit intoharsha-iiiv:mainfrom
Pldesch:main
Open

feat: Include OpenAPI tags in the tool interface#59
Pldesch wants to merge 1 commit intoharsha-iiiv:mainfrom
Pldesch:main

Conversation

@Pldesch
Copy link

@Pldesch Pldesch commented Mar 1, 2026

Add openapi tags into the MCP Tool description to allow more fine-grained control for filtering

Summary by CodeRabbit

  • New Features
    • Tools now support tags for enhanced organization and categorization. Tags are extracted from operation metadata, enabling better filtering and grouping of available tools.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

The changes introduce a tags field to MCP tool definitions. The McpToolDefinition interface is extended with an optional tags property, and the tool extraction logic is updated to populate this field from operation tags during parsing.

Changes

Cohort / File(s) Summary
MCP Tool Tags Support
src/types/index.ts, src/parser/extract-tools.ts
Adds optional tags: string[] field to McpToolDefinition interface and populates it from operation.tags during tool extraction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 With tags so neat, our tools align,
Each operation's labels shine,
A cottontail's organizing delight,
Structured data, organized right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding OpenAPI tags to the tool interface for filtering purposes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/types/index.ts (1)

66-66: Add a brief field doc for tags for consistency.

Line 66 introduces a useful field, but it’s the only property in McpToolDefinition without 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: Copy operation.tags defensively 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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee9fc3 and edcee2a.

📒 Files selected for processing (2)
  • src/parser/extract-tools.ts
  • src/types/index.ts

@Pldesch
Copy link
Author

Pldesch commented Mar 4, 2026

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant