Skip to content

limit tool name length #69

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DougieHauser
Copy link

Describe your changes

Resolves #64

Attempts to filter tools whose operation_id + server name are too long.

Note: The codebase seems to have logic overlap between the functions server.py/_filter_tools and convert.py/def convert_openapi_to_mcp_tools - I didn't want to rock the boat too much on my first attempted contribution, but I would be happy to try my luck at refactoring (perhaps in a separate ticket).

Issue ticket number and link (if applicable)

#64

Screenshots of the feature / bugfix

Checklist before requesting a review

  • [V] Added relevant tests
  • [V] Run ruff & mypy
  • [V] All tests pass

Copy link
Collaborator

@shira-ayal shira-ayal left a comment

Choose a reason for hiding this comment

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

First of all - thank you so much for contributing!
I had a few comments on the code itself, but also wanted to remark on the implementation in general.

I think hard-coding skipping on tools is not a good practice - even if some clients don't accept long tool names, it's not something defined by the spec so we shouldn't enforce it for all MCPs.
It will be better to implement by configuring the max length as an optional argument when generating the MCP based on the FastAPI app, roughly like this:

mcp = FastApiMCP(app, max_tool_name_length=60)

(with max_tool_name_length default to None).

Would be happy to see these changes implemented and then approve!

Regarding your note - it will be best to open an Issue (assigned to yourself) and then implement in a separate PR :)

Thanks again for your contribution!

@DougieHauser DougieHauser requested a review from shira-ayal April 19, 2025 22:19
Copy link

codecov bot commented Apr 19, 2025

Codecov Report

Attention: Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fastapi_mcp/server.py 78.57% 3 Missing ⚠️
fastapi_mcp/openapi/convert.py 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@shahar4499
Copy link
Contributor

I think syncing tadata-org:main latest changes back to your branch would resolve test coverage issues

@DougieHauser DougieHauser force-pushed the feature/limit-tool-name-length branch from 5c80302 to 2494832 Compare April 20, 2025 12:24
@DougieHauser
Copy link
Author

DougieHauser commented Apr 20, 2025

@shahar4499 - Thanks, I rebased my branch with the "upstream" repo but couldn't get the codecov bot to run again.

I then tried to push a "dummy commit" in order to trigger it, but again, no such luck.

Is there anything I'm missing?

Thanks.

@DougieHauser DougieHauser force-pushed the feature/limit-tool-name-length branch from 8571f99 to 4388fc6 Compare April 20, 2025 16:12
Copy link
Collaborator

@shira-ayal shira-ayal left a comment

Choose a reason for hiding this comment

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

Nice!
Can you address the small notes I commented?
Other than that, looks fine by me

@DougieHauser DougieHauser requested a review from shira-ayal April 21, 2025 13:01
@DougieHauser DougieHauser force-pushed the feature/limit-tool-name-length branch from e02d7c2 to f4fabd6 Compare April 22, 2025 11:36
@DougieHauser DougieHauser force-pushed the feature/limit-tool-name-length branch from f4fabd6 to 985a9df Compare April 23, 2025 15:18
@DougieHauser
Copy link
Author

Hey @shira-ayal, just pinging to see if there are any more expected changes.
Thanks.

@shira-ayal
Copy link
Collaborator

Hi @DougieHauser !
Looks great, waiting for @shahar4499 to take a final look before we merge :)

@shira-ayal shira-ayal self-requested a review April 24, 2025 15:11
@DougieHauser
Copy link
Author

Hi @DougieHauser !
Looks great, waiting for @shahar4499 to take a final look before we merge :)

Hey @shahar4499, just a quick ping. 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.

Combined Server and tool name should not exceed 60 characters
3 participants