miniMCP
miniMCP
一个轻量级项目,演示了如何通过模型上下文协议 (Model Context Protocol, MCP) 实现并连接本地 AI 模型(使用 Ollama)与自定义工具。
在这个项目中,AI 充当数据库助手,可以使用 CRUD(创建、读取、更新、删除)操作来查询和管理内存数据库。
项目结构
server.py: 这是使用FastMCP创建的 MCP 服务器。它维护一个内存数据库,并公开以下工具 (tools):创建项目 (
create_item)读取单个项目 (
read_item)同时读取多个项目 (
read_multiple_items)更新项目 (
update_item)删除项目 (
delete_item)
client.py: 这是通过终端进行交互的客户端。它通过标准输入/输出流 (stdio) 连接到 MCP 服务器,读取可用工具,并与用户及 Ollama LLM (gemma4:e4b) 建立聊天循环。requirements.txt: 包含项目主要依赖项的文件。
Related MCP server: Modular MCP Server with Python Tools
要求与依赖
在启动项目之前,请确保已安装:
Python 3.10+
Ollama 已安装并在你的机器上运行。
本仓库使用的模型,默认为
gemma4:e4b。你可以使用以下命令下载它:ollama run gemma4:e4b
安装
克隆仓库并进入其文件夹:
git clone <url-del-repo> miniMCP cd miniMCP创建并激活虚拟环境(可选,但强烈推荐):
python -m venv .venv # En Windows: .\.venv\Scripts\activate # En macOS/Linux: source .venv/bin/activate安装必要的依赖项:
pip install -r requirements.txt pip install gradio
使用方法
该项目包含客户端/服务器配置,但客户端负责自行启动服务器,因此你只需要运行客户端:
python client.py直接在控制台中输入你的问题。
交互示例
你可以尝试告诉 AI:
"创建一个 ID 为 'tarea1'、内容为 '买牛奶' 的项目"
"显示 'tarea1' 的内容"
"更新 'tarea1',并告诉我牛奶应该是脱脂的"
"读取 'tarea1' 和 'tarea2'"
"删除 ID 'tarea1'"
AI 将自动执行 server.py 中的工具,而无需你直接编写代码或调用。
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Cloud-hosted MCP server for durable AI memory
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP-Server from your Database optimized for LLMs and AI-Agents. Supports PostgreSQL, MySQL, ClickHouse, Snowflake, MSSQL, BigQuery, Oracle Database, SQLite, ElasticSearch, DuckDB548Apache 2.0
- FlicenseNot gradedqualityDmaintenanceA demo MCP server that enables users to interact with various tools through natural language, including note management, weather queries, calculations, file operations, and shell commands. Uses Ollama for intent detection and structured command parsing from free text input.-
- FlicenseNot gradedqualityAmaintenanceAn MCP server that exposes relational databases (PostgreSQL/MySQL) to AI agents with natural language to SQL query support.19-
- FlicenseNot gradedqualityDmaintenanceEnables natural language database queries by combining Ollama's language models with SQLite database access through an MCP server.-