-
Notifications
You must be signed in to change notification settings - Fork 25
MCP Architecture
Shazzadul Islam edited this page Jul 29, 2025
·
5 revisions
The Model Context Protocol (MCP) is a standardized way for AI models to interact with external tools and data sources. Each MCP server in this project follows the JSON-RPC 2.0 specification and implements specific capabilities.
Functions that the AI can call to perform actions:
- Execute operations (file processing, calculations, etc.)
- Return structured results to the AI model
- Accept parameters for customization
Data sources that can be read or queried:
- Static files or dynamic data
- URI-based access patterns
- Support for different MIME types
Pre-defined prompt templates for common tasks:
- Standardized interaction patterns
- Parameterized templates
- Context-aware suggestions
# Standard MCP server setup
app = Server("server-name")
@app.list_tools()
async def handle_list_tools() -> list[Tool]:
return [
Tool(
name="tool_name",
description="Tool description",
inputSchema={
"type": "object",
"properties": {
"param": {"type": "string"}
}
}
)
]@app.call_tool()
async def handle_call_tool(name: str, arguments: dict) -> list[TextContent]:
if name == "tool_name":
result = process_data(arguments["param"])
return [TextContent(type="text", text=result)]- Client Request: AI model requests available tools
- Server Response: Server lists available tools with schemas
- Tool Execution: AI calls specific tool with parameters
- Result Return: Server processes and returns structured results
- Use clear, descriptive tool names
- Provide comprehensive input schemas
- Return structured, parseable results
- Implement proper error handling
- Follow async/await patterns for I/O operations