1、前言
MCP Server 示例
AndyM129
README
详见原文,以获得最新的内容:【AI入门】MCP 初探 - 掘金
1、前言
大模型火了一阵子了,最近又火了一个技术 —— MCP
在看了一些介绍后,恰巧之前通过 Ollama 也部署了本地大模型,正好可以试试本地 MCP,兴许可以「以后 自己开发些 MCP,然后通过本地大模型调用」,这样就能摆脱 UI、Terminal 来执行特定的操作了~~
2、准备
2.1、安装 Ollama
访问 Ollama 官网: https://ollama.com/download ,下载需要的版本,并安装:
安装指定的大模型:
【PS】我目前在本地安装了以下几个大模型:
$ ollama list
NAME ID SIZE MODIFIED
mistral-small3.1:latest b9aaf0c2586a 15 GB 12 minutes ago
phi4:latest ac896e5b8b34 9.1 GB 7 weeks ago
deepseek-r1:14b ea35dfe18182 9.0 GB 8 weeks ago
bge-m3:latest 790764642607 1.2 GB 8 weeks ago
deepseek-r1:32b 38056bbcbb2d 19 GB 8 weeks ago
llama3.2:latest a80c4f17acd5 2.0 GB 8 weeks ago
2.2、安装 CherryStudio
这是一个本地大模型的客户端,以便配合 Ollama 来使用本地大模型
访问官网 https://docs.cherry-ai.com/cherry-studio/download ,下载需要的版本,并安装:
3、安装、开发 MCP
以下内容,以通过 Python 开发为例进行介绍。
3.1、安装 UV
uv
是一个 MCP 推荐的 Python 包管理工具,可以参考其官网 进行安装: https://docs.astral.sh/uv/getting-started/installation/#installation-methods
我的安装方式&过程如下:
$ wget -qO- https://astral.sh/uv/install.sh | sh
downloading uv 0.6.14 aarch64-apple-darwin
no checksums to verify
installing to /Users/mengxinxin/.local/bin
uv
uvx
everything\'s installed!
To add $HOME/.local/bin to your PATH, either restart your shell or run:
source $HOME/.local/bin/env (sh, bash, zsh)
source $HOME/.local/bin/env.fish (fish)
WARNING: The following commands are shadowed by other commands in your PATH: uv uvx
$ uv version
uv 0.6.14 (a4cec56dc 2025-04-09)
3.2、创建&初始化一个 MCP项目
# 初始化项目
$ uv init hello_mcp_server
# 进入项目目录
$ cd hello_mcp_server
# 创建环境
$ uv venv
# 激活环境
$ source .venv/bin/activate
# 安装依赖
$ uv add "mcp[cli]"
3.3、开发&调试 MCP
示例代码如下:
from mcp.server.fastmcp import FastMCP
from pydantic import Field
# Initialize FastMCP server
mcp = FastMCP("hello-mcp-server", log_level="ERROR")
# 注册工具的装饰器,可以很方便的把一个函数注册为工具
@mcp.tool()
async def hello_mcp_server(username: str = Field(description="用户名")) -> str:
"""当用户向 MCP 打招呼时,调用此工具
Args:
username: 用户名
Returns:
回复用户的问好
"""
return f"Hello, {username},我是 MCP 示例!"
def main():
print("Hello from hello-mcp-server!")
if __name__ == "__main__":
main()
执行如下名,可获得调试地址:
$ mcp dev hello_mcp_server.py
Starting MCP inspector...
⚙️ Proxy server listening on port 6277
🔍 MCP Inspector is up and running at http://127.0.0.1:6274 🚀
在浏览器中访问该调试地址: http://127.0.0.1:6274 ,并点击 Connect:
然后如图操作、验证工具:
4、接入 CherryStudio
4.1、添加 MCP 服务器
4.2、设置大模型
4.3、在对话中启用 MCP 服务器
4.4、完成,试一下吧~
以上,搞定,收工~ ✌🏻
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.