mcp-server
使用 Ollama 的本地 MCP 服务器
一个本地 Python 项目,将 Ollama 语言模型连接到 MCP 服务器。该模型可以发现服务器的工具,决定何时调用其中一个,接收结果,并生成简洁的最终响应。
flowchart TD
U["User question"] --> C["Python MCP client"]
C --> O["Ollama llama3.2:3b"]
O --> C
C --> S["Local MCP server"]
S --> D["Student JSON data"]可用工具
工具 | 用途 |
| 将两个显式提供的数字相加 |
| 返回内置的演示学生档案 |
| 按姓名和请求的字段在 |
Related MCP server: py-mcp-students
要求
Python 3.11+
已安装并正在运行的 Ollama
Ollama 模型
llama3.2:3b
Windows 设置
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
ollama pull llama3.2:3b
python client.py客户端通过当前使用的 Python 解释器自动启动 server.py。您无需在单独的终端中启动服务器。
示例问题
What is 10 + 20?Tell me about Pranay.Where is Ananya studying?What is Saranya studying?
项目结构
mcp-server/
├── client.py
├── server.py
├── files/
│ └── students.json
├── tests/
│ └── test_server.py
└── requirements.txt工具结果修复
Ollama 期望工具结果消息中包含已执行的 tool_name。客户端会包含此字段,并将可用的工具定义传入后续调用,从而使模型能够在 MCP 工具运行后生成最终响应。
数据说明
files/students.json 是演示数据。在公开或生产环境中使用此项目之前,请将其替换为虚构或已获同意使用的数据。
This server cannot be deployed
Maintenance
Related MCP Connectors
Search 16,000+ API operations and 95 built tools by need, then call any of them by name
31PDF, image, video, OCR, screenshot, SQL, QR and text tools for agents. No API key, no signup.
Search and run data, text, code, PDF and web APIs. Requests not stored. Network tools need a key.
Discover, inspect and run 63,000+ agent tools from one balance. Pay per call, no subscriptions.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceExposes custom Python functions as tools and integrates with Ollama for tool calling.4MIT
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to manage student records through natural language by wrapping a simple HTTP student server's endpoints as MCP tools.-
- FlicenseAqualityCmaintenanceEnables arithmetic calculation, current time lookup, and attendance retrieval through natural language tool calls.3-
- FlicenseAqualityCmaintenanceEnables an LLM client to perform basic arithmetic on two numbers — addition, subtraction, multiplication, and division — plus reverse a supplied text string, through five simple tools exposed over stdio. Inputs and structured text results follow JSON schemas, with invalid operations such as division by zero surfaced as tool errors.5-