Replies: 2 comments
-
|
Answering my own question. This feels a little silly but it works if it helps someone else. import httpx
from fastmcp import FastMCP
import asyncio
API_KEY = "XXXXXX"
openapi_spec = httpx.get("https://example1.com/openapi.json", headers={'x-api-key': API_KEY}).json()
client = httpx.AsyncClient(base_url="https://example1.com", headers={'x-api-key': API_KEY})
API_KEY_2 = "XXXXXX"
openapi_spec2 = httpx.get("https://example2.com/openapi.json").json()
client2 = httpx.AsyncClient(base_url="https://example2.com", headers={'x-api-key': API_KEY_2})
mcp = FastMCP.from_openapi(
openapi_spec=openapi_spec,
client=client,
name="The Actual Server",
)
mcp2 = FastMCP.from_openapi(
openapi_spec=openapi_spec2,
client=client2,
name="The server thats a temporary vehicle to leverage OpenAPI integration"
)
server2_tools = asyncio.run(mcp2.get_tools())
for key in server2_tools.keys():
mcp.add_tool(server2_tools[key]) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Same question. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any clean way to combine multiple servers created from OpenAPI specs or rather use multiple OpenAPIs specs to create a single server? Perhaps I'm missing it somewhere. Maybe a different way to get there is one server using from_openapi and then if there was something like
Tool.from_openapi_route()that could create an additional tool to add.I'm sure there a host of people that will tell me to just make two separate servers and turn them both on. The problem is when it comes to prompts. If I have prompts on the server that ask for tool calls from multiple servers...
Obviously I could just manually create the tools within server A that would otherwise make up server B... but that really takes some of the magic out of this for me...
Beta Was this translation helpful? Give feedback.
All reactions