File size: 1,001 Bytes
d71b95a |
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 |
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI(title="Example MCP Server")
class MCPRequest(BaseModel):
metadata: str
source_type: str
viz_format: str
@app.get("/")
def root():
return {"status": "ok", "message": "Example MCP server running"}
@app.post("/mcp")
def mcp_endpoint(req: MCPRequest):
"""Simple example endpoint that returns a sample mermaid diagram and summary.
This is intentionally minimal — a real MCP server would run the agent pipeline and
return an appropriate visualization and structured metadata.
"""
# Create a small mermaid graph that incorporates the source_type for demonstration
mermaid = f"graph TD\n A[{req.source_type}] --> B[Processed by Example MCP]"
summary = f"Example MCP processed source_type={req.source_type}, viz_format={req.viz_format}"
return {"mermaid": mermaid, "visualization": mermaid, "summary": summary}
# Run with: uvicorn mcp_example.server:app --reload --port 9000 |