crewai-mcp

MCP运维云端

提供方 Khan07fahad

运维云端 stdio · 本地进程 API Key 社区 / 第三方 Zed
查看接入方式

An AI calculator service based on MCP protocol and CrewAI, enabling real-time mathematical calculations via SSE transport.

一句话选型结论

按资料字段整理

crewai-mcp 属于运维云端类 MCP 服务器,stdio · 本地进程,API Key,可直接接入 Zed,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类运维云端 传输方式stdio · 本地进程 鉴权API Key 部署方式本地部署
GitHub 星标 1 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

运维云端
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

Local Deployment AI Calculator MCP Protocol Python CrewAI Integration SSE Transport Mathematical Calculation

支持客户端

Zed

适用场景

Local DeploymentAI CalculatorMCP Protocol

安装与配置

stdio · 本地进程 API Key
客户端在本机拉起子进程,数据不出本机
# Ensure virtual environment is activated source vecal/bin/activate # Verify activation which python # Must show path to vecal/bin/python # Reinstall dependencies pip install -r requirements.txt # Verify installation python -c "import mcp; import crewai; print('All good!')"

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
云资源查询

查实例、存储、账单等云上资源状态。

部署与发布

把部署、重启、回滚这类操作接进对话。

监控与告警

拉取监控指标,异常时让模型帮你判断。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Zed,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好API Key对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在运维云端场景里让模型直接调用外部能力的人。
  • 已经在用 Zed 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
crewai-mcp当前 未标注 stdio · 本地进程 本地部署 有 2026-01-11
lobehub 未标注 stdio · 本地进程 本地部署 有 2026-04-11
TrendRadar 未标注 stdio · 本地进程 本地部署 有 2026-04-13
Ui Tars Desktop 8a825770 未标注 stdio · 本地进程 本地部署 有 2026-05-17
ruflo 未标注 stdio · 本地进程 本地部署 有 2026-04-13
FastGPT 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

运维云端
字段来自项目仓库与公开索引,中文说明由本站标注
提供方Khan07fahad上游标注的维护方 Khan07fahad
分类运维云端本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式API Key远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-01-11上游最后核验时间

详细介绍

18.8 KB
来自项目仓库与上游目录的原文,未做删改

🧮 MCP Calculator Server with CrewAI - Complete Guide

📋 Table of Contents

  1. Overview
  2. Architecture
  3. Prerequisites
  4. Setup Instructions
  5. Understanding the Components
  6. Running the Application
  7. How It Works
  8. Troubleshooting
  9. Advanced Usage

🎯 Overview

This project demonstrates how to integrate Model Context Protocol (MCP) with CrewAI to create AI agents that can perform mathematical calculations through a remote server. The system consists of:

  • MCP Calculator Server: Provides calculator tools via SSE (Server-Sent Events) transport
  • CrewAI Agent: Consumes MCP tools to perform calculations
  • SSE Protocol: Enables real-time bidirectional communication

What You'll Build

An AI-powered calculator system where CrewAI agents automatically discover and use calculator tools (add, subtract, multiply, divide) exposed by an MCP server.


🏗️ Architecture

System Overview```

┌─────────────────────────────────────────────────────────────────┐
│ User Input │
│ "Calculate 15 + 27 and multiply by 3" │
└────────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ CrewAI System │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Calculator Agent (crew.py) │ │
│ │ • Receives user requests │ │
│ │ • Plans calculation steps │ │
│ │ • Uses MCPServerAdapter to access tools │ │
│ └────────────────────┬─────────────────────────────────────┘ │
│ │ │
│ ┌────────────────────▼─────────────────────────────────────┐ │
│ │ MCPServerAdapter (crewai_tools) │ │
│ │ • Connects to MCP server via SSE │ │
│ │ • Discovers available tools │ │
│ │ • Translates tool calls to MCP protocol │ │
│ └────────────────────┬─────────────────────────────────────┘ │
└────────────────────────┼─────────────────────────────────────────┘
│
│ SSE Connection
│ (HTTP/SSE Transport)
│
┌────────────────────────▼─────────────────────────────────────────┐
│ MCP Calculator Server │
│ (mcp_calculator_server.py) │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ FastMCP Server │ │
│ │ • Exposes calculator tools via MCP protocol │ │
│ │ • Handles SSE connections │ │
│ │ • Processes tool execution requests │ │
│ └──────────────────────────────────────────────────────────┘ │
│ │
│ 🔧 Available Tools: │
│ ├─ add_numbers(a, b) │
│ ├─ subtract_numbers(a, b) │
│ ├─ multiply_numbers(a, b) │
│ └─ divide_numbers(a, b) │
│ │
│ 📡 Endpoints: │
│ ├─ GET /sse → SSE stream (responses) │
│ └─ POST /messages → Tool calls (requests) │
└───────────────────────────────────────────────────────────────────┘

---
## 🔧 Prerequisites

### System Requirements
- **Python**: 3.12 or higher
- **Operating System**: macOS, Linux, or Windows
- **Terminal**: Access to command line

### Required API Keys
- **OpenAI API Key**: Required for CrewAI agent (uses GPT models)
  - Get it from: https://platform.openai.com/api-keys
  - Or use alternative LLM providers (see Advanced Usage)

---

## 📦 Setup Instructions

### Step 1: Project Structure

Create the project directory:```bash
mkdir -p ~/Desktop/crewai-mcp
cd ~/Desktop/crewai-mcp

Your project should have this structure:```
calculater/
├── mcp_calculator_server.py # MCP server with calculator tools
├── crew.py # CrewAI agent that uses MCP tools
├── interactive_calculator.py # Interactive CLI version
├── requirements.txt # Python dependencies


### Step 2: Create Virtual Environment```bash
cd ~/Desktop/crewai-mcp

# Create virtual environment named 'vecal'
python3 -m venv vecal

# Activate it
source vecal/bin/activate

# Verify activation (you should see (vecal) in your prompt)
which python
# Should output: /Users/[username]/Desktop/crewai-mcp/vecal/bin/python

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Set Up Environment Variables

Create .env file:```bash
cat > .env << 'EOF'

OpenAI API Key (required for CrewAI)

OPENAI_API_KEY=your-api-key-here

Optional: Model configuration

OPENAI_MODEL_NAME=gpt-4o-mini

EOF


**Important**: Replace `your-api-key-here` with your actual OpenAI API key!

Load environment variables:```bash
# Option 1: Export manually
export OPENAI_API_KEY=&quot;your-actual-api-key&quot;

# Option 2: Use dotenv (automatically loaded by crew.py)
# Just make sure .env file exists with correct values

🎓 Understanding the Components

Component 1: MCP Calculator Server

File: mcp_calculator_server.py

Key Elements:

  1. FastMCP Server Initialization```python
    mcp = FastMCP("calculator-server")
Creates an MCP server instance.

2. **Tool Definitions**```python
@mcp.tool()
def add_numbers(a: int, b: int) -&gt; int:
    &quot;&quot;&quot;Add two numbers together.&quot;&quot;&quot;
    return a + b

Each function decorated with @mcp.tool() becomes an MCP tool.

  1. SSE Transport Setup```python
    sse = SseServerTransport("/messages/")
Creates SSE transport that handles bidirectional communication.

4. **Route Configuration**```python
routes=[
    Route(&quot;/sse&quot;, endpoint=handle_sse, methods=[&quot;GET&quot;]),
    Mount(&quot;/messages/&quot;, app=sse.handle_post_message),
]
  • /sse: Client connects here to receive responses
  • /messages/: Client posts tool execution requests here

Component 2: CrewAI Agent

File: crew.py

Key Elements:

  1. MCPServerAdapter```python
    with MCPServerAdapter(server_params) as tools:
Automatically:
- Connects to MCP server via SSE
- Discovers available tools
- Converts them to CrewAI-compatible tools

2. **Agent Definition**```python
calculator_agent = Agent(
    role=&quot;Mathematical Calculator&quot;,
    goal=&quot;Perform calculations...&quot;,
    tools=tools,  # MCP tools injected here
    ...
)
  1. Task Definition```python
    calculator_task = Task(
    description="Calculate X + Y...",
    agent=calculator_agent,
    ...
    )

4. **Crew Execution**```python
calculator_crew.kickoff()

Starts the agent, which automatically uses MCP tools as needed.

🚀 Running the Application

Terminal Setup

You'll need TWO terminal:

Terminal 1: MCP Server```bash

Navigate to project directory

cd ~/Desktop/crewai-mcp

Activate virtual environment

source vecal/bin/activate

Start MCP server

python mcp_calculator_server.py


**Expected Output**:```
======================================================================
🧮 MCP Calculator Server (SSE Transport)
======================================================================

✅ Using FastMCP with SSE over HTTP
📡 Server running on: http://localhost:8000

🔧 Available Tools:
  • add_numbers(a, b)
  • subtract_numbers(a, b)
  • multiply_numbers(a, b)
  • divide_numbers(a, b)

💡 This is a proper MCP server with SSE transport!
   Can be used with CrewAI MCPServerAdapter

Press Ctrl+C to stop
======================================================================

INFO:     Started server process [12345]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

✅ Server is ready when you see "Uvicorn running..."

Terminal 2: CrewAI Agent```bash

Open NEW terminal tab/window

cd ~/Desktop/crewai-mcp

Activate virtual environment

source vecal/bin/activate

Set API key (if not in .env)

export OPENAI_API_KEY="your-api-key-here"

Run CrewAI agent

python crew.py


**Expected Output**:```
Available tools from MCP server: [&#x27;add_numbers&#x27;, &#x27;subtract_numbers&#x27;, &#x27;multiply_numbers&#x27;, &#x27;divide_numbers&#x27;]

🚀 Starting calculation tasks...

[Agent: Mathematical Calculator]
[Task: Perform calculations...]

Working on: Add 15 and 27...
Using tool: add_numbers
Tool result: 42

Working on: Subtract 10 from 50...
Using tool: subtract_numbers
Tool result: 40

Working on: Multiply 8 by 6...
Using tool: multiply_numbers
Tool result: 48

Working on: Divide 100 by 4...
Using tool: divide_numbers
Tool result: 25.0

======================================================================
✨ FINAL RESULT
======================================================================
# Calculation Results

1. **Addition**: 15 + 27 = 42
2. **Subtraction**: 50 - 10 = 40
3. **Multiplication**: 8 × 6 = 48
4. **Division**: 100 ÷ 4 = 25.0

All calculations completed successfully!
======================================================================

Interactive Mode```python

from crewai import Agent, Task, Crew, Process
from crewai_tools import MCPServerAdapter

def run_interactive_calculator():
server_params = {
"url": "http://localhost:8000/sse",
"transport": "sse"
}

print(&quot;\n&quot; + &quot;=&quot;*70)
print(&quot;🧮 Interactive Calculator Agent&quot;)
print(&quot;=&quot;*70 + &quot;\n&quot;)

try:
    with MCPServerAdapter(server_params) as tools:
        calculator_agent = Agent(
            role=&quot;Mathematical Calculator Assistant&quot;,
            goal=&quot;Help users perform calculations using MCP calculator tools.&quot;,
            backstory=&quot;A friendly calculator AI with arithmetic capabilities.&quot;,
            tools=tools,
            reasoning=True,
            verbose=True,
        )

        while True:
            print(&quot;\n📝 Enter your calculation (or &#x27;quit&#x27; to exit):&quot;)
            user_input = input(&quot;&gt; &quot;).strip()

            if user_input.lower() in [&#x27;quit&#x27;, &#x27;exit&#x27;, &#x27;q&#x27;]:
                print(&quot;\n👋 Goodbye!\n&quot;)
                break

            if not user_input:
                continue

            task = Task(
                description=f&quot;Calculate: {user_input}&quot;,
                expected_output=&quot;The calculation result with explanation.&quot;,
                agent=calculator_agent,
            )

            crew = Crew(
                agents=[calculator_agent],
                tasks=[task],
                verbose=False,
                process=Process.sequential
            )

            result = crew.kickoff()
            print(f&quot;\n✨ Result: {result}\n&quot;)

except Exception as e:
    print(f&quot;\n❌ Error: {e}\n&quot;)

if name == "main":
run_interactive_calculator()


Run it:```bash
python interactive_calculator.py

🔍 How It Works

Complete Request Flow

Let's trace what happens when the agent calculates 15 + 27:

1. Initialization Phase```python

crew.py starts

with MCPServerAdapter(server_params) as tools:


**What happens**:
1. MCPServerAdapter connects to `http://localhost:8000/sse`
2. Server creates session: `session_id=xxxxxxx`
3. Server sends: `data: /messages/?session_id=xxxxxxx`
4. Adapter extracts session ID and keeps SSE connection open
5. Adapter requests tool list: `{&quot;method&quot;: &quot;tools/list&quot;}`
6. Server returns: `[&quot;add_numbers&quot;, &quot;subtract_numbers&quot;, ...]`
7. Adapter creates CrewAI tools from MCP tool schemas

#### 2. Agent Execution Phase```python
calculator_crew.kickoff()

What happens:
1. CrewAI reads task description: "Add 15 and 27"
2. Agent (powered by GPT) decides to use add_numbers tool
3. Agent generates tool call: add_numbers(a=15, b=27)

3. Tool Execution Phase

In MCPServerAdapter:```python

Adapter intercepts tool call

tool_call = {
"name": "add_numbers",
"arguments": {"a": 15, "b": 27}
}

Converts to MCP protocol

mcp_request = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add_numbers",
"arguments": {"a": 15, "b": 27}
}
}

POSTs to /messages/?session_id=xxxxxxx

response = requests.post(url, json=mcp_request)


**On Server Side**:```python
# Server receives request at /messages/?session_id=xxxxxxx
# Looks up session by ID
# Routes message through SSE transport streams
# Calls the actual Python function:
result = add_numbers(15, 27)  # Returns 42

# Sends result back via SSE stream
sse_response = {
    &quot;jsonrpc&quot;: &quot;2.0&quot;,
    &quot;id&quot;: 1,
    &quot;result&quot;: {
        &quot;content&quot;: [{&quot;type&quot;: &quot;text&quot;, &quot;text&quot;: &quot;42&quot;}]
    }
}

Back in MCPServerAdapter:```python

Listens on SSE stream

Receives result: "42"

Converts to CrewAI format

Returns to agent


#### 4. Response Phase```python
# Agent receives: 42
# Agent uses result to formulate answer
# Agent continues with next calculation

Data Flow Diagram```

User Input: "Add 15 and 27"
↓
CrewAI Agent (decides to use tool)
↓
MCPServerAdapter.add_numbers(15, 27)
↓
[Converts to JSON-RPC]
↓
POST /messages/?session_id=xxxxxxx
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {"name": "add_numbers", "arguments": {"a": 15, "b": 27}}
}
↓
MCP Server receives & processes
↓
Python function: add_numbers(15, 27) → 42
↓
[Formats as MCP response]
↓
SSE Stream ══════════════════════════>
event: message
data: {"result": {"content": [{"text": "42"}]}}
↓
MCPServerAdapter receives via SSE
↓
[Extracts result: 42]
↓
Returns 42 to Agent
↓
Agent: "The sum of 15 and 27 is 42"


---

## 🐛 Troubleshooting

### Issue 1: Server Won&#x27;t Start

**Error**: `Address already in use`

**Solution**:```bash
# Find process using port 8000
lsof -ti:8000

# Kill it
kill -9 $(lsof -ti:8000)

# Or use different port
# In mcp_calculator_server.py, change:
uvicorn.run(app, host=&quot;0.0.0.0&quot;, port=8001)
# And in crew.py:
&quot;url&quot;: &quot;http://localhost:8001/sse&quot;

Issue 2: CrewAI Can't Connect

Error: Error connecting to Calculator MCP server

Checklist:```bash

1. Is server running?

curl http://localhost:8000/sse

Should connect and stream data

2. Check server logs in Terminal 1

Look for errors or connection attempts

3. Verify URL in crew.py

server_params = {
"url": "http://localhost:8000/sse", # Must match server port
"transport": "sse"
}

4. Test server manually

curl -N http://localhost:8000/sse

Should see: event: endpoint, data: /messages/?session_id=...


### Issue 3: Missing OpenAI API Key

**Error**: `OPENAI_API_KEY is required`

**Solution**:```bash
# Option 1: Set in terminal
export OPENAI_API_KEY=&quot;sk-...&quot;

# Option 2: Create .env file
echo &#x27;OPENAI_API_KEY=sk-...&#x27; &gt; .env

# Option 3: Use alternative LLM (see Advanced Usage)

Issue 4: Tool Calls Fail

Error: Invalid request parameters

Debug Steps:```bash

1. Check server logs for detailed error

2. Verify tool exists

curl http://localhost:8000/sse

Wait for initialization, then check available tools

3. Test tool manually

Get session ID from SSE connection, then:

curl -X POST "http://localhost:8000/messages/?session_id=YOUR_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add_numbers",
"arguments": {"a": 5, "b": 3}
}
}'


### Issue 5: Dependencies Not Found

**Error**: `ModuleNotFoundError: No module named &#x27;mcp&#x27;`

**Solution**:```bash
# Ensure virtual environment is activated
source vecal/bin/activate

# Verify activation
which python
# Must show path to vecal/bin/python

# Reinstall dependencies
pip install -r requirements.txt

# Verify installation
python -c &quot;import mcp; import crewai; print(&#x27;All good!&#x27;)&quot;

📚 Summary

What You Built

  1. MCP Calculator Server: Exposes mathematical operations via standardized protocol
  2. CrewAI Integration: AI agents automatically discover and use remote tools
  3. SSE Transport: Efficient real-time communication between components

Key Takeaways

✅ MCP enables tool standardization - Any client can use your calculator
✅ SSE provides real-time communication - Low latency, persistent connections
✅ CrewAI makes AI agents easy - Automatic tool discovery and usage
✅ Modular architecture - Server and agents are independent


📖 Additional Resources

  • MCP Specification: https://spec.modelcontextprotocol.io/
  • FastMCP Documentation: https://gofastmcp.com/
  • CrewAI Documentation: https://docs.crewai.com/
  • SSE Specification: https://html.spec.whatwg.org/multipage/server-sent-events.html

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
crewai-mcp 怎么安装?

在客户端按下面的安装命令接入:# Ensure virtual environment is activated source vecal/bin/activate # Verify activation which python # Must show path to vecal/bin/python # Reinstall dependencies pip install -r requirements.txt # Verify installation python -c "import mcp; import crewai; print('All good!')"。装完在客户端配置里引用同一个包或端点。

crewai-mcp 怎么在 Zed 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

crewai-mcp 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

crewai-mcp 需要 API Key 吗?

资料标注需要API Key认证,使用前准备好对应凭据,并按最小权限配置。

crewai-mcp 支持哪些客户端?

资料标注支持 Zed;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

crewai-mcp 能提供哪些能力?

资料显示能力标签包括 Local Deployment、AI Calculator、MCP Protocol、Python、CrewAI Integration、SSE Transport。具体工具清单以官方文档为准。

crewai-mcp 需要什么运行环境?

运行时为 python;属于本地进程,需要在本机装好运行环境。

crewai-mcp 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-01-11。