Skip to content

fix(openapi): skip OPTIONS operations when generating tools - #340

Open
dajiaohuang wants to merge 1 commit into
AmoyLab:mainfrom
dajiaohuang:fix/openapi-skip-options
Open

dajiaohuang wants to merge 1 commit into
AmoyLab:mainfrom
dajiaohuang:fix/openapi-skip-options

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 23, 2026 •

Copy link
Copy Markdown

The OpenAPI converter intends to skip CORS OPTIONS operations, but kin-openapi returns uppercase HTTP methods. Comparing with lowercase options creates an extra OPTIONS tool. Compare case-insensitively and strengthen the existing skip-options test to require exactly one tool.

Validation:

  • Strengthened existing regression fails before the fix (two tools instead of one).
  • go test ./pkg/openapi -count=1 passes.
  • go build ./cmd/... passes on Windows with Go 1.26.3.

The test scope corresponds to make test TEST_PACKAGES=./pkg/openapi; the full service suite was not run because this task permits offline synthetic fixtures only. No live MCP servers, model APIs, or backend services were started.

Summary by Sourcery

Prevent OpenAPI conversion from generating tools for CORS OPTIONS operations.

Bug Fixes:

  • Skip CORS OPTIONS operations regardless of HTTP method casing so they do not generate unintended tools.

Tests:

  • Strengthen the OpenAPI converter regression test to require exactly one generated tool.

@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The converter now skips OPTIONS operations case-insensitively, preventing an unwanted CORS tool when kin-openapi reports uppercase methods; the regression test requires exactly one generated tool and confirms the existing GET behavior.

Flow diagram for case-insensitive OPTIONS tool filtering

flowchart LR
    Spec[OpenAPI specification] --> Converter[Converter.Convert]
    Converter --> Method[Path operation method]
    Method --> Check["strings.EqualFold(method, options)"]
    Check -->|true| Skip[Skip CORS OPTIONS operation]
    Check -->|false| Tool[Generate MCP tool]
Loading

File-Level Changes

Change Details Files
Make CORS OPTIONS filtering robust to the uppercase HTTP methods returned by kin-openapi.
  • Use case-insensitive comparison when identifying OPTIONS operations.
  • Continue excluding OPTIONS operations from generated tools while preserving other methods.
pkg/openapi/converter.go
Strengthen regression coverage to verify that OPTIONS operations do not produce extra tools.
  • Require the converted configuration to contain exactly one tool.
  • Retain validation that the GET tool is present and uses the operation summary as its description.
pkg/openapi/converter_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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