We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Agarwal-Saurabh/multiapimcpserver'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
local_spec.py•1.83 kB
"""
Example: Using the FastMCP OpenAPI server with a local OpenAPI specification.
"""
import asyncio
import os
from pathlib import Path
from fastmcp_openapi import OpenAPIServer
async def main():
"""Example using a local OpenAPI specification file."""
# Get the path to the example OpenAPI spec
examples_dir = Path(__file__).parent
spec_file = examples_dir / "simple_api.json"
if not spec_file.exists():
print(f"Example spec file not found: {spec_file}")
return
# Create server
server = OpenAPIServer("Local API Server")
# Add the local API specification
await server.add_openapi_spec(
name="simple_api",
spec_url=str(spec_file),
base_url="https://api.example.com/v1" # Override the base URL
)
# Show what was loaded
apis = server.list_apis()
print("Loaded APIs:")
for api in apis:
print(f" - {api['name']}: {api['title']} v{api['version']}")
print(f" Description: {api['description']}")
print(f" Operations: {api['operations']}")
print(f" Base URL: {api['base_url']}")
# Show operations for the API
api_info = server.get_api_info("simple_api")
if api_info:
print(f"\nAvailable operations:")
for op in api_info["operations"]:
print(f" - {op['operation_id']}: {op['method']} {op['path']}")
if op['summary']:
print(f" Summary: {op['summary']}")
# Run the server
print("\nStarting MCP server with stdio transport...")
print("The server will now expose the API operations as MCP tools.")
print("Tool names will be prefixed with the API name (e.g., 'simple_api_listUsers')")
server.run(transport="stdio")
if __name__ == "__main__":
asyncio.run(main())