Creating Tools Without Creating Server - Dummy FastMCPOpenAPI Implementation #2260
Replies: 2 comments 1 reply
-
|
The more I think about it/test the runtime, it seems that the way I have currently implemented it, it doesn't really save too much time the larger the openapi spec is that we want to grab. But I do think there is room to improve and it could be an easy addition to the code - a lighter weight way to update the registered tools as a batch. Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
If your approach is working for you, I suggest keeping it - registering tools from an OpenAPI spec is many orders of magnitude slower than creating the actual server object, to the point that we have performance tests for it in the repo! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I have been using FastMCP's from_openapi feature and am encountering an issue that I think would be a good addition to the repo (I tried to create a PR to demonstrate but permission denied - unsurprisingly :) ). Our use case is this: we are creating an MCP server and then leaving it up for a long time. At startup, we are batch registering all of our openapi tool definitions, but expect that customers will edit the docs to fit their own needs. We would therefore like a lightweight way to send updated docs and reregister the updated tools using those docs. From what I could find, it seems that the only way to do this directly from openapi docs (and not using a tool transformation) would be to create another server, then loop through the tools and reregister the changed/new ones on the primary server. While this could work, it is resource intensive, as it involves spinning up a server every time there could be changes. Therefore, I propose that the repo includes a file called something like DummyFastMCPOpenAPI, that does NOT extend FastMCP class and only implements the portion of FastMCPOpenAPI that grabs and registers tools without calling init on the parent class FastMCP. This would, in my opinion, be a lighter weight solution, as the only resource intensive actions would be the call to the openapi resource and then any formatting to create the tools objects. I have spun up a simple version of it on my local, and it works well. Wondering if there would be a way to add this in, or if there already exists this capability and I am simply not finding it for some reason. It seemed to me that while you can use add_tool, there isn't an easy way to add singular tools to a pre-configured server based on openapi specs instead of actual Tool objects.
Cheers, and I look forward to hearing more on this possible new addition! Thanks!
TLDR: I would love to create a dummy "server" that only creates tools from openapi specs, and doesn't actually create the fully fledged server object.
Note: The way the file is currently set up is that it would reside in the path src/fastmcp/experimental/server/openapi
dummy_server.py
Beta Was this translation helpful? Give feedback.
All reactions