Skip to main content
Model-Context-Protocol (MCP) rethinks how AI agents integrate with external systems. Instead of having developers write bespoke API integrations for every use case, MCP lets services register as callable tools that agents can invoke. This shifts the integration burden from application code to the agent, enabling more flexible, composable workflows. In practice, an MCP server exposes one or more well-defined functions (endpoints) with explicit input and output schemas. When an agent runs, it discovers and calls these functions to query or mutate external state. That makes it straightforward to extend an assistant’s capabilities—plug in an MCP server for a system and the agent can use it without additional glue code. For example, a TechDocs assistant could query customer, order, inventory, or ticketing systems via MCP endpoints. If a user asks, “What’s the status of order 1234?”, the agent can call an MCP that queries the order-management system, receive the structured response, and compose a natural-language reply that includes the order state.
A hand-drawn system diagram showing a user asking "What's the status of order #1234" to Tech Corp's AI chat assistant and agent. The agent connects to internal knowledge (a vector DB) and external systems (customer database, inventory/support) via an MCP/API to fetch the information.

Minimal FastAPI MCP server example

Below is a concise, practical example: a FastAPI-based MCP that exposes a simple customer lookup function. It demonstrates the typical pieces of an MCP server:
  • A web app that exposes a function endpoint the agent can call.
  • Typed request/response models so agents know how to call the function.
  • A persistence layer (here, an in-memory dict) — replace with your production DB.
Use this as a template for a real integration (SQL, MongoDB, or any service).
Run the server with uvicorn:
Example MCP client request (what an agent or other client would send):
Example JSON response:

Key components and best practices

This structure—define endpoints and schemas once—lets any compatible agent call your MCP server to fetch or modify external state. Many ecosystems publish reusable MCP adapters for common services (e.g., source control, databases, productivity tools), letting you plug them into agents without custom integration work.
MCP servers should clearly define input and output schemas (e.g., via OpenAPI / Pydantic). This makes it easy for agents to discover and call them reliably. In production, secure these endpoints (authentication, authorization, rate-limiting) before exposing them to agents.
Use this pattern to make your AI assistants actionable: define function surfaces, provide strict schemas, and secure endpoints—then let the agent do the integration work.

Watch Video