Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions mcp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
"""
MCP Server for IggyAPI - FHIR Implementation Guide Search and Retrieval

This module converts the IggyAPI FastAPI application into an MCP server using FastMCP.
It provides MCP tools for searching and retrieving FHIR Implementation Guides and profiles.

Author: John Grimes
"""

from fastmcp import FastMCP
from fastmcp.server.openapi import RouteMap, MCPType
from main import app

# Create the MCP server from the FastAPI app
mcp = FastMCP.from_fastapi(
app=app,
name="IggyAPI-MCP",
route_maps=[
# GET requests with path parameters become ResourceTemplates
# This includes /igs/{ig_id}/profiles and /igs/{ig_id}/profiles/{profile_id}
RouteMap(
methods=["GET"],
pattern=r".*/\{[^}]+\}.*",
mcp_type=MCPType.RESOURCE_TEMPLATE
),
# All other GET requests become Resources
# This includes /igs/search and /status
RouteMap(
methods=["GET"],
pattern=r".*",
mcp_type=MCPType.RESOURCE
),
# POST requests become Tools
# This includes /refresh-cache
RouteMap(
methods=["POST"],
pattern=r".*",
mcp_type=MCPType.TOOL
),
]
)

if __name__ == "__main__":
# Run the MCP server
# Try stdio transport which is more reliable with Claude Code
mcp.run(transport="stdio")
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ sqlalchemy==2.0.35
packaging==24.1
apscheduler==3.10.4
tenacity==8.5.0
spacy==3.7.6
en-core-web-md @ https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.7.1/en_core_web_md-3.7.1-py3-none-any.whl
spacy==3.8.7
en-core-web-md @ https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.8.0/en_core_web_md-3.8.0-py3-none-any.whl
fastmcp>=2.9.2