Token导航 LogoToken导航TokenDH.com
ouss MCP logo
运维云端未说明官方级别未说明来源级核验

ouss MCP

MCP Server

一个基于Python、FastMCP、Pydantic v2和Docker构建的生产级模型上下文协议服务器,支持搜索、计算、文件资源和提示处理等功能。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
API集成DockerClaudeFastMCPClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Oussama-nasri

提供方

Oussama-nasri

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

为了便于您复制,我已经包装了整个更新 README.md 单个Markdown代码块中的内容。

我还整合了 viztracer 指令是开发工作流程的核心部分。

# MCP Server — Python

A production-ready Model Context Protocol server built with Python, FastMCP, Pydantic v2, and Docker.

## Quick start

1. Clone and enter the project

git clone && cd ouss_mcp

2. Copy and fill in your environment variables

cp .env.example .env

Edit .env — at minimum set API_KEY to a 32+ char random string:

python -c "import secrets; print(secrets.token_hex(32))"

3. Install dependencies (requires uv)

pip install uv && uv sync

4. Run in stdio mode (for Claude Desktop)

python -m mcp_server.server

5. Run in SSE mode (for remote access)

TRANSPORT=sse python -m mcp_server.server


## 项目结构

src/mcp_server/ ├── server.py Entry point, server bootstrap ├── config.py Typed settings via pydantic-settings ├── handlers/ │ ├── tools/ │ │ ├── search.py search tool │ │ └── calculator.py calculate tool │ ├── resources/ │ │ └── file_resource.py file:// URI handler │ └── prompts/ │ └── summarize_prompt.py summarize + code_review prompts ├── middleware/ │ ├── auth.py Constant-time API key verification │ ├── rate_limiter.py Sliding window rate limiter (in-process + Redis) │ └── logging.py Structured JSON logging via structlog ├── services/ │ ├── search_service.py Search logic (swap for real backend) │ └── calculator_service.py AST-based safe math evaluator └── utils/ └── resilience.py Retry + backoff helpers (tenacity)


## 可用工具

|工具|说明|
|------|-------------|
| `search` |搜索知识库。Args: `query` (str), `limit` (int,默认值10)|
| `calculate` |安全地计算数学表达式。Args: `expression` (str)|

## 可用资源

|URI|描述|
|-----|-------------|
| `file://` |列出文件根目录中的所有文件|
| `file://{path}` |读取特定文件(仅限UTF-8文本,最大10 MB)|

## 可用提示

|提示|描述|
|--------|-------------|
| `summarize` |结构化摘要。Args: `text`, `style` (项目符号/段落/tldr), `language`, `max_words` |
| `code_review` |代码审查。Args: `code`, `language`, `focus` (安全/性能/风格/全部)|

## 运行测试

uv run pytest # all tests uv run pytest tests/unit/ # unit tests only uv run pytest tests/integration/ # integration tests only uv run pytest --cov=src # with coverage


## 跟踪和性能可视化

使用 `viztracer` 调试延迟并可视化MCP处理程序和异步任务的执行流。

### 1.生成跟踪

使用以下命令通过跟踪器运行服务器 `--log_async` 标记以正确捕获事件循环:

Start the server with tracing enabled

viztracer --log_async -o mcp_trace.json start_mcp.py


### 2.执行工作量

当服务器运行时,在单独的终端中执行测试客户端或自动测试:

python src/mcp_client/test_mcp.py


### 3.保存和查看

1. 返回服务器终端并按 **`Ctrl+C`**.
1. 等待消息 `Saving trace data to disk...`.
1. 打开基于Chrome的交互式查看器:

vizviewer mcp_trace.json


> **导航提示:** 使用 `W/S` 为了放大/缩小, `A/D` 向左/向右移动,以及 `F` 缩放以适应整个轨迹。

## Docker部署

Build and start all services

cd docker docker compose up -d

View logs

docker compose logs -f mcp

Stop

docker compose down


## VPS设置(一次性)

On your VPS

sudo apt update && sudo apt install -y docker.io docker-compose-plugin nginx certbot python3-certbot-nginx

Clone the repo

sudo git clone /opt/ouss_server sudo cp /opt/mcp-server/.env.example /opt/mcp-server/.env

Fill in /opt/mcp-server/.env

Install systemd service

sudo cp /opt/mcp-server/docker/mcp-server.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable --now mcp-server

Set up Nginx + TLS

sudo cp /opt/mcp-server/docker/nginx.conf /etc/nginx/sites-available/mcp-server sudo ln -s /etc/nginx/sites-available/mcp-server /etc/nginx/sites-enabled/

Edit the server_name in nginx.conf, then:

sudo certbot --nginx -d mcp.yourdomain.com sudo systemctl reload nginx


## 环境变量

|变量|必填|默认|描述|
|----------|----------|---------|-------------|
| `API_KEY` |是|--|32+字符密钥|
| `TRANSPORT` |没有| `stdio` | `stdio` 或 `sse` |
| `HOST` |没有| `0.0.0.0` |绑定地址|
| `PORT` |没有| `3000` |绑定端口|
| `LOG_LEVEL` |没有| `INFO` | `DEBUG/INFO/WARNING/ERROR` |
| `DATABASE_URL` |没有| `""` |Postgres异步URL|
| `REDIS_URL` |没有| `redis://localhost:6379` |重定向URL|
| `RATE_LIMIT_PER_MINUTE` |没有| `100` |每分钟请求数|
| `FILE_ROOT` |没有| `/data/files` |文件的根目录://资源|

## 添加新工具

1. 创建 `src/mcp_server/services/my_service.py` 使用纯异步逻辑。
1. 创建 `src/mcp_server/handlers/tools/my_tool.py` 带着一个 `register(mcp)` 功能。
1. 导入和调用 `my_tool.register(mcp)` 在 `server.py`.
1. 在中编写测试 `tests/unit/test_my_service.py`.

目录标签

目录标签

API集成DockerClaudeFastMCP模型服务Python本地部署Python服务器Docker部署API服务

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

api-key

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明api-key部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP