# MCP (Model Context Protocol)

## What is MCP?

MCP, short for Model Context Protocol, is a standardized protocol for communication between LLMs and external services. It enables various large language models such as Anthropic Claude, OpenAI GPT, and Google Gemini to interact with other services using the same set of standardized rules.

### What Can MCP Help With?

With MCP, LLMs are no longer just chatbots that can talk -- they become intelligent work partners that can actually execute tasks.

#### **Connect to External Data Sources in Real Time** <a href="#ji-shi-lian-jie-wai-bu-zi-liao-yuan" id="ji-shi-lian-jie-wai-bu-zi-liao-yuan"></a>

* Access databases
* Read file systems
* Integrate with cloud services

#### **Proactively Invoke Tools** <a href="#zhu-dong-diao-yong-gong-ju" id="zhu-dong-diao-yong-gong-ju"></a>

* Execute code
* Operate applications

***

## How MCP Works

The operating principle of MCP is illustrated in the diagram below:

| Component                  | Description                                                                                                                                                                                                                                                                                                      |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Frontend (User-facing)** | Users issue commands through UI or SDK                                                                                                                                                                                                                                                                           |
| **AI Model Layer**         | LLM calls MCP Client to interact with external tools in a standardized format                                                                                                                                                                                                                                    |
| **Protocol Layer (MCP)**   | <p>Uses <code>JSON-RPC 2.0</code> to define tool interfaces, Schema validation, and streaming transport.<br><code>JSON-RPC 2.0</code> is a communication protocol that defines "request and response" structures in JSON format, allowing LLMs to communicate with various programs using the same language.</p> |
| **MCP Servers**            | <p>Receive model requests and interact with actual tools or data systems.<br>In addition to hosting your own MCP Servers, you can also use <a href="../remote-mcp/remote-mcp">Remote MCP services</a> to connect LLMs with other services.</p>                                                                   |
| **External Systems**       | Various real-world resources: databases, APIs, Git, file systems, etc.                                                                                                                                                                                                                                           |

### MCP Workflow Diagram

Through this workflow, LLMs can use a unified language to interact with various external programs, helping you complete tasks that would otherwise require manual effort.

### MCP Use Cases

#### Case 1: Organizing Google Drive Files via MCP -- Document Search and Summarization

Tell the LLM the task in natural language:

> Find all documents related to "2024 Annual Budget" in Google Drive and compile them into a summary report.

The LLM will automatically determine which MCP tools to invoke based on your needs, such as the `search_files` tool.

**MCP Workflow:**

**Actions performed by the AI:**

1. Search for documents containing the keyword "2024 Annual Budget"
2. Read the contents of the 5 documents found
3. Analyze key points from each document
4. Generate a consolidated summary report
5. Provide budget analysis recommendations

**Result delivered to the user:**

```
Found 5 related documents:

1. [2024 Annual Budget Proposal.docx]
   - Total Budget: NT$ 50,000,000
   - Main Categories: Personnel 60%, Operations 25%, R&D 15%

2. [Q1 Budget Execution Report.xlsx]
   - Execution Rate: 92%
   - Over-budget Item: Marketing expenses +8%

3. [Budget Revision v2.pdf]
   - Adjustment Recommendation: Increase R&D budget by 10%

... (other document summaries)
```

***

#### Case 2: Connecting Google Sheets and Slack via MCP -- Scheduled Weekly Report Generation Sent to a Channel

The LLM can connect multiple external service tools via MCP, as shown in the workflow below:

A scheduling service triggers the LLM weekly to perform the same query task:

The LLM will automatically determine which MCP tools to invoke based on your needs, such as the `search_sheet` and `query_sheet` tools.

The AI assistant's weekly processing workflow:

1. Search for the "Sales Data" spreadsheet
2. Read the spreadsheet values
3. Generate a consolidated summary report based on requirements, such as average revenue, year-over-year growth, etc.
4. Automatically send the compiled results to a Slack channel

***

## Core Value of MCP <a href="#he-xin-jia-zhi-zong-jie" id="he-xin-jia-zhi-zong-jie"></a>

#### **LLM Provides Intelligence** <a href="#llm-ti-gong-zhi-hui" id="llm-ti-gong-zhi-hui"></a>

* Natural language understanding
* Reasoning and decision-making
* Knowledge synthesis
* Creative generation
* Anomaly detection
* Predictive analysis

#### **MCP Provides Capabilities** <a href="#mcp-ti-gong-neng-li" id="mcp-ti-gong-neng-li"></a>

* Connect to various tools
* Execute real actions
* Cross-system integration
* Secure and reliable
* Standardized communication

By combining LLM and tools, LLMs evolve from "<mark style="color:blue;">just talking</mark>" to "<mark style="color:blue;">getting things done</mark>", becoming all-around work partners that can understand, think, and execute.

***

## **MaiAgent MCP Integration Advantages**

### **Support for Multiple Network Protocols**

MaiAgent MCP supports a variety of network protocols, ensuring efficient and stable communication across different application scenarios. Through a flexible protocol selection mechanism, the system can automatically choose the most suitable transport method based on actual needs, providing enterprises with the best integration experience.

| Protocol                | Communication Direction                  | Connection Type               | Supported by MaiAgent |
| ----------------------- | ---------------------------------------- | ----------------------------- | --------------------- |
| **Standard HTTP/HTTPS** | Bidirectional (Request/Response)         | Short-lived                   | ✅                     |
| **Streamable HTTP**     | Bidirectional                            | Short or Long-lived           | ✅                     |
| **WebSocket (WS/WSS)**  | Bidirectional Streaming                  | Persistent                    | ✅                     |
| **SSE**                 | Unidirectional Streaming (Server→Client) | Long-lived                    | ✅                     |
| **Unix Domain Socket**  | Bidirectional                            | Persistent (Local)            | ✅                     |
| **Named Pipe**          | Bidirectional                            | Persistent (Local)            | ❌                     |
| **Stdio**               | Bidirectional                            | Persistent (Process Lifetime) | ❌                     |

### Rapid Integration via Graphical Interface

MaiAgent provides an intuitive graphical interface that lets you quickly integrate MCP tools without writing code. The interface provides fields for environment variables and parameters -- you can directly enter the settings you need, and the system will automatically read and apply them to the MCP tool.

{% hint style="info" %}
For instructions on creating MCP tools, see: [User Guide -- Creating MCP Tools](https://docs.maiagent.ai/tools/setup)
{% endhint %}

With the services provided by MaiAgent above, you can freely choose the protocols your enterprise needs and quickly integrate them into the MaiAgent system. Through MaiAgent's comprehensive platform services, you can build your own <mark style="color:blue;">intelligent AI assistant</mark>.
