-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
58 lines (43 loc) · 1.35 KB
/
server.py
File metadata and controls
58 lines (43 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""OpenMedica MCP Server - AI agent integration via FastMCP."""
import os
import asyncio
from mcp.server import Server
from mcp.types import Tool
from mcp.tools import (
clinical_search_tool,
document_lookup_tool,
call_clinical_search,
call_document_lookup,
)
APP_NAME = "openmedica"
APP_VERSION = "1.0.0"
server = Server(APP_NAME)
@server.list_tools()
async def list_tools():
"""List all available MCP tools."""
return [clinical_search_tool, document_lookup_tool]
@server.call_tool()
async def call_tool(name: str, arguments: dict):
"""Handle tool calls."""
if name == "clinical_search":
return await call_clinical_search(**arguments)
elif name == "document_lookup":
return await call_document_lookup(**arguments)
else:
raise ValueError(f"Unknown tool: {name}")
def get_api_url() -> str:
"""Get API base URL from environment."""
return os.getenv("OPENMEDICA_API_URL", "http://localhost:8000/api/v1")
def main():
"""Run the MCP server."""
from mcp.server.stdio import stdio_server
async def run():
async with stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
server.create_initialization_options(),
)
asyncio.run(run())
if __name__ == "__main__":
main()