Repository navigation
|
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 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... |
Replies: 5 comments 3 replies
|
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]) |
|
Same question. |
|
@jbnitorum i have 1 doubt is there any way to group multiple apis under one tool within api spec. like if we have 2 open apis spec (4 apis in 1 spec and 6 apis in other spec) can we create just 2 tools instead of creating 10 tools? |
|
hi @jbnitorum @duanckham anyone using open api spec are u not facing this issue #3113 |
|
Hi @jbnitorum did u face any problems with auto generated tools from open api spec https://www.jlowin.dev/blog/stop-converting-rest-apis-to-mcp?utm_source=chatgpt.com |
Answering my own question. This feels a little silly but it works if it helps someone else.