Selector AI FastMCP

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Manages environment variables for configuration, including Selector AI API keys and URLs.

  • Runs the MCP server in a lightweight container with health checks, and the client can spawn the Docker container for interactive sessions.

  • Used for cloning the repository during installation process.

选择器 AI FastMCP

此代码库提供了 Selector AI 模型上下文协议 (MCP) 的完整实现。它包含一个支持流式传输的服务器和一个基于 Docker 的交互式客户端,后者通过 stdin/stdout 进行通信。

✨ 特点

✅ 服务器

与 FastMCP 兼容并基于 Python 构建

实时 SSE 流支持

与 Selector AI 进行交互式 AI 聊天

最小样板

内置容器编排健康检查

请求/响应记录和重试

✅ 客户

Python 客户端通过 Docker 生成服务器

支持 CLI 和编程访问

通过 stdin 和 stdout 读取/写入

使用 .env 配置环境变量

🚀 快速入门

先决条件

Python 3.8+

Docker

选择器 AI API 密钥

选择器 API URL

⚙️ 安装

克隆存储库

git clone https://github.com/automateyournetwork/selector-mcp-server

cd 选择器-ai-mcp

安装 Python 依赖项

pip 安装 -r 要求.txt

设置环境变量创建一个.env 文件:

SELECTOR_URL= https://你的选择器api-url

SELECTOR_AI_API_KEY=你的 API 密钥

🐳 Dockerfile

服务器使用以下 Dockerfile 在轻量级容器中运行:

来自 python:3.11-slim

工作目录/应用程序

复制 requirements.txt 。

运行 pip install -r requirements.txt

复制 。 。

CMD [“python”,“-u”,“mcp_server.py”]

健康检查 --interval=30s --timeout=30s --start-period=5s
CMD python -c“导入套接字;s = socket.socket(socket.AF_UNIX,socket.SOCK_STREAM);s.connect('/tmp/mcp.sock');s.send(b'{“tool_name”:“ready”} \n');数据=s.recv(1024);s.close();导入json;结果=json.loads(data);退出(如果result.get('status')=='ready'则退出0,否则退出1)”||退出1

构建 Docker 镜像

docker build -t 选择器-mcp 。

🧠 使用客户端

启动客户端

这将生成 Docker 容器并打开一个交互式 shell。

python mcp_客户端.py

CLI 会话示例

您>什么是 AIOps?

选择器> AIOps 是指将 AI 应用于 IT 运营...

程序化访问

从 selector_client 导入 call_tool、spawn_server

proc = spawn_server()

call_tool(proc,“准备就绪”)

响应 = call_tool(proc,“ask_selector”,{“content”:“什么是 AIOps?”})

打印(响应)

🖥️ 与 Claude Desktop 一起使用

如果您正在与 Claude Desktop 集成,您可以运行此服务器并在本地公开套接字或 HTTP 端点:

使用 Docker 或本机运行服务器:

python mcp_服务器.py

从 Claude Desktop 的外部工具配置连接到套接字或 HTTP 端点。

确保您的消息符合以下格式:

{ "method": "tools/call", "tool_name": "ask_selector", "content": "What can you tell me about device S6?" }

Claude Desktop 将通过标准输出接收 AI 的结构化响应。

🛠️ 构建你自己的容器

要自定义此设置:

分叉或克隆此 repo

修改 selector_fastmcp_server.py 以集成您喜欢的模型或路由逻辑

重建 Docker 镜像:

docker build -t my-custom-mcp 。

更新客户端以生成 my-custom-mcp:

“docker”、“运行”、“-i”、“--rm”、“my-custom-mcp”

📁 项目结构

选择器-ai-mcp/

├── selector_fastmcp_server.py # Server: MCP + Selector AI integration ├── selector_client.py # Client: Docker + stdin/stdout CLI ├── Dockerfile # Container config ├── requirements.txt # Python deps ├── .env # Environment secrets └── README.md # You are here

✅ 要求

requirements.txt 中的依赖项:

请求

python-dotenv

📜 许可证

Apache 许可证 2.0

-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议 (MCP) 服务器可通过具有流式传输功能的服务器和基于 Docker 的客户端通过 stdin/stdout 进行通信,实现与 Selector AI 的实时交互式 AI 聊天。

Appeared in Searches

ID: z6gj8vdi7r