探求しよう

Get In Touch
Lisbon,
[email protected]
Ph: +351 920 559 258
Back

MCP vs API

Summary

In late 2024, Anthropic introduced the Model Context Protocol (MCP), a transformative open standard designed to bridge the gap between large language models (LLMs) and the real-world data, tools, and services they need to deliver truly context-aware, actionable AI experiences. MCP acts as a universal “USB-C port” for AI, standardizing how applications provide context and access to external resources, replacing fragmented, custom integrations with a single, scalable protocol.

What Will You Learn in This Blog Post?

  • The fundamentals of the Model Context Protocol (MCP) and why it was created

  • How MCP’s architecture enables seamless, secure connections between LLMs and external data sources or tools

  • The key differences and similarities between MCP and traditional APIs

  • Real-world application examples and Python code snippets to get started

  • Important considerations for security, governance, and integration

  • How MCP is shaping the future of agentic AI and enterprise data science

MCP: The Universal Connector for AI

Why MCP Matters

Modern LLMs are powerful but isolated-they can’t natively access up-to-date business data, files, or services. Historically, every new integration required a custom connector, leading to a tangled web of “N×M” integrations that were hard to scale and maintain. MCP solves this by providing:

  • A universal, open protocol for connecting any AI assistant to any data source or tool

  • Standardized primitives for tools (actions), resources (data), and prompt templates

  • Dynamic discovery, allowing AI agents to find and use new capabilities at runtime, without code changes

MCP Architecture and Components

MCP’s architecture is based on a client-server model using JSON-RPC 2.0 for communication. Key components include:

  • MCP Host: The AI application (like a chat assistant or coding IDE)

  • MCP Clients: Connectors within the host that initiate sessions

  • MCP Servers: External services exposing capabilities (e.g., databases, file systems, APIs) via the MCP protocol

Servers advertise their available tools, resources, and prompts through machine-readable catalogs. This allows AI agents to dynamically discover and invoke new functionalities-much like plugging a device into a universal port.

MCP Capabilities

  • Tools: Discrete actions the AI can perform (e.g., “get weather”, “search email”)

  • Resources: Read-only data items (e.g., files, database records)

  • Prompt Templates: Predefined prompts or workflows to guide AI behavior

MCP vs. Traditional APIs

Feature MCP (Model Context Protocol) Traditional APIs (REST, GraphQL, etc.)
Purpose AI/LLM-specific context and tool access General system integration
Dynamic Discovery Yes-agents query servers at runtime No-endpoints are static, clients must update
Standardization Universal interface for all services Each API is unique, custom adapters needed
Integration Complexity “N+M” (protocol-level standardization) “N×M” (custom connectors per integration)
Underlying Implementation Often wraps existing APIs Direct system access
Example Use Case AI agent fetching latest sales data Web app retrieving user info from a database

MCP often acts as a wrapper around traditional APIs, translating LLM-friendly requests into API calls and returning results in a standardized format912.

Application Example: Connecting an LLM to a Database with MCP

Suppose a data scientist wants an AI agent to analyze recent sales data stored in PostgreSQL. With MCP, this is straightforward:

  1. Set up an MCP server for PostgreSQL (many are open-source and ready to deploy).

  2. Configure the AI application (MCP host) to connect to the MCP server.

  3. The LLM can now discover and use database tools (e.g., “query sales by region”) dynamically.

Example: Using MCP in Python

Install the MCP SDK:

python
pip install anthropic-model-context-protocol

Sample code to connect to an MCP server and list available tools:

python

from anthropic_model_context_protocol import MCPClient

# Connect to the MCP server (e.g., PostgreSQL)
client = MCPClient(server_url=“http://localhost:8080”)

# List available tools
tools = client.list_tools()
print(“Available tools:”, tools)

# Call a tool (e.g., run a query)
result = client.call_tool(“query_sales_by_region”, {“region”: “EMEA”})
print(“Query Result:”, result)

This approach allows the AI agent to adapt to new tools or data sources as they become available, without code changes or redeployment.

Important Points to Remember

  • MCP is AI-native: Designed specifically for LLMs and agentic workflows, not just generic system integration.

  • Dynamic, scalable, and secure: Agents can discover and use new capabilities at runtime, with strong user consent and privacy controls built in.

  • Ecosystem is growing fast: Hundreds of open-source MCP servers exist for databases, file systems, cloud storage, communication platforms, and more.

  • Not a replacement for APIs: MCP often leverages traditional APIs under the hood, acting as a unifying layer for AI applications9.

  • Ideal for enterprise data science: MCP enables seamless, governed access to proprietary data and tools, unlocking new workflows for analytics, automation, and decision support.

Conclusion

The Model Context Protocol is rapidly becoming the backbone of next-generation, context-aware AI systems. By standardizing how LLMs access external data and tools, MCP eliminates integration bottlenecks and empowers AI agents to deliver richer, more actionable insights-whether in Databricks, Azure, or any enterprise environment. As the ecosystem matures, expect MCP to be at the heart of every truly agentic AI workflow.