MCP Shared Services

MCP Shared Services

Modular monolithic FastAPI shared AI service platform providing config center, prompt registry, LLM gateway, RAG service, secret manager, tool registry, and MCP server wrapper.

Category
Visit Server

README

MCP Shared Services

模块化单体 FastAPI 共享 AI 服务平台。

本地开发

uv --cache-dir .uv-cache sync --extra dev --no-managed-python --python D:\sorftWare_package\anaconda\python.exe
uv --cache-dir .uv-cache run python -m pytest -v
uv --cache-dir .uv-cache run uvicorn app.main:app --host 0.0.0.0 --port 8400 --reload

前端控制台:

cd frontend
npm install
npm run dev -- --host 0.0.0.0 --port 5173

默认访问地址:

http://localhost:5173

初始化开发数据:

uv --cache-dir .uv-cache run python -m scripts.seed_dev_data

冒烟检查:

uv --cache-dir .uv-cache run python -m scripts.smoke_test
uv --cache-dir .uv-cache run python -m scripts.check_pgvector

当前范围

  • Config Center
  • Prompt Registry
  • LLM Gateway
  • RAG Service V1
  • Secret Manager V1
  • Tool Registry V1
  • MCP Server wrapper

Secret Manager

Secret Manager 用于按项目和环境加密保存敏感配置,例如模型 API Key、RTC AppKey、外部工具凭证。

生产环境应配置稳定的加密密钥:

$env:SECRET_ENCRYPTION_KEY="your-stable-secret-key"

也可以使用 Fernet key。未配置时会使用本地开发兜底密钥,适合开发联调,不适合生产。

HTTP 接口:

  • PUT /api/v1/secrets/{project_id}/{env}/{secret_key}:新增或更新 secret
  • GET /api/v1/secrets/{project_id}/{env}/{secret_key}:读取 secret 元数据,不返回明文
  • GET /api/v1/secrets?project_id=...&env=...:查询 secret 元数据列表
  • POST /api/v1/secrets/{project_id}/{env}/{secret_key}/resolve:解析 secret 明文,供受控服务端调用

普通元数据响应会返回 secret_ref,例如:

secret://finance_media/dev/ark_api_key

后续 Tool Registry 和 Agent Gateway 可以保存这个引用,而不是保存明文。

Tool Registry

Tool Registry 用于按项目和环境登记可供 Agent 使用的工具目录。它只保存工具元数据和凭证引用,不负责直接执行工具。

适合登记的工具类型:

  • http:外部或内部 HTTP API
  • mcp:MCP Server 暴露的工具
  • builtin:平台内置工具或后续 Agent Gateway 内部能力

核心字段:

  • endpoint_config:工具连接信息,例如 HTTP URL、方法,或 MCP server/tool 名称
  • input_schema / output_schema:工具输入输出结构
  • auth_typenoneapi_keybearerbasiccustom
  • secret_ref:Secret Manager 返回的引用,例如 secret://finance_media/dev/news_api_token
  • permission_scopeprivateprojectpublic
  • tags:工具标签,便于 Agent 按任务筛选

HTTP 接口:

  • PUT /api/v1/tools/{project_id}/{env}/{tool_id}:新增或更新工具定义
  • GET /api/v1/tools/{project_id}/{env}/{tool_id}:读取工具定义
  • GET /api/v1/tools?project_id=...&env=...&tool_type=...&enabled=true&tag=...:查询工具列表

MCP Server

四个共享 HTTP 服务也暴露为 MCP 工具,默认通过 Streamable HTTP 启动,使用独立端口 8401

uv --cache-dir .uv-cache run python -m app.mcp_server

默认地址:

http://127.0.0.1:8401/mcp

MCP Streamable HTTP Host 配置示例:

{
  "mcpServers": {
    "mcp-shared-services": {
      "url": "http://127.0.0.1:8401/mcp"
    }
  }
}

如果需要改端口:

$env:MCP_PORT="8401"
uv --cache-dir .uv-cache run python -m app.mcp_server

如果需要 stdio 模式,可以显式指定:

$env:MCP_TRANSPORT="stdio"
uv --cache-dir .uv-cache run python -m app.mcp_server

当前工具覆盖:

  • Secret Manager:secret_upsertsecret_get_metadatasecret_listsecret_resolve
  • Tool Registry:tool_registry_upserttool_registry_gettool_registry_list
  • Config Center:config_get_taskconfig_upsert_taskconfig_list_change_logs
  • Prompt Registry:prompt_createprompt_create_versionprompt_publish_versionprompt_render
  • RAG Service:rag_create_knowledge_baserag_ingest_documentrag_searchrag_create_evidence_pack
  • LLM Gateway:llm_generatellm_json_generatellm_image_generate

下游项目共享平台地址

本地开发统一使用 http://localhost:8400 作为 MCP_Cluster 共享平台地址,避免和营销项目 backend_api:8000 冲突。

  • 营销内容编排:SHARED_PLATFORM_BASE_URL=http://localhost:8400
  • 智能客服 LLMServer:SHARED_PLATFORM_BASE_URL=http://localhost:8400

如果使用 PostgreSQL 并已安装 pgvector,启动或 seed 时会自动执行:

  • CREATE EXTENSION IF NOT EXISTS vector
  • rag_chunks 增加 embedding_vector vector(...)
  • 回填已有 chunk 的向量并优先走 pgvector 检索

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured