Skip to main content
Glama
slackwarecps

MCP Simple Server

by slackwarecps

MCP 简易服务器 (HTTP 网桥)

这是一个简化的 MCP (Model Context Protocol) 服务器,通过 HTTP POST 接口暴露工具。它允许远程 LLM 和代理通过隧道或直接访问安全地调用本地或特定功能。

🚀 技术配置

  • 端口: 3030

  • 端点: /mcp

  • 方法: POST

  • 认证: Authorization: Bearer senha-facil-123

  • 协议: JSON-RPC 2.0 (适配 HTTP)


Related MCP server: local-env-mcp

🧪 使用 CURL 进行远程测试

您可以使用以下命令从任何具有网络访问权限的机器(或通过 Wireguard VPN)验证服务器的运行情况。

1. 列出可用工具

curl -X POST http://10.7.0.1:3030/mcp \
  -H "Authorization: Bearer senha-facil-123" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

2. 调用 'hello' 工具

curl -X POST http://10.7.0.1:3030/mcp \
  -H "Authorization: Bearer senha-facil-123" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"hello","arguments":{"name":"Fabão"}},"id":2}'

♊ 配置 Gemini-CLI (远程)

为了让您本地机器或其他 VPS 上的 gemini-cli 访问此服务器,您需要在 Gemini CLI 的配置文件(通常位于 ~/.gemini/config.yaml 或通过命令)中进行配置。

由于此服务器使用直接 HTTP(而非标准的 stdio),您可以使用“包装器”,或者如果服务器已扩展,则配置 SSE 访问,或者在可用时使用 fetch 插件。

配置示例(假设使用 stdio-to-http 代理):

# No gemini-cli


gemini mcp add remote-server --command "npx @modelcontextprotocol/inspector http://10.7.0.1:3030/mcp"

在 ~/.gemini/settings.json 文件中

"mcpServers": {                                                                                                                      
    "local-mcp": {                                                                                                                                     
      "url": "http://192.168.1.100:3030/mcp",                                                                                                          
      "headers": {                                                                                                                                     
        "Authorization": "Bearer senha-facil-123"                                                                                                      
      }                                                                                                                                                
    }             
  }

注意:请将 IP 替换为正确的地址(例如 VPN 的 10.7.0.1)。


🤖 配置 Claude Code

Claude Code(以及 Claude Desktop)通常期望一个本地命令。要访问此远程服务器:

  1. 编辑 claude_desktop_config.json 文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Linux: ~/.config/Claude/claude_desktop_config.json

  2. 添加配置:

{
  "mcpServers": {
    "mcp-simple-server": {
      "command": "curl",
      "args": [
        "-s",
        "-X", "POST",
        "http://10.7.0.1:3030/mcp",
        "-H", "Authorization: Bearer senha-facil-123",
        "-H", "Content-Type: application/json",
        "-d", "{\"jsonrpc\":\"2.0\",\"method\":\"tools/call\",\"params\":<params>}"
      ]
    }
  }
}

提示:为了实现更稳健的集成,建议使用将 stdio 转换为服务器 HTTP API 的 mcp-proxy。


💬 配置 ChatGPT (GPT Codex / Actions)

要将此服务器用作 ChatGPT 中的 Action:

  1. 前往 Custom GPTs -> Create a GPT -> Configure -> Create new action。

  2. 在 Authentication 字段中,选择 API Key,选择 Bearer 并输入:senha-facil-123。

  3. 在 Schema 字段中,使用 OpenAPI 规范(下方为简化示例):

openapi: 3.0.0
info:
  title: MCP Simple Server
  version: 1.0.0
servers:
  - url: http://195.35.42.89:3030 # IP Público ou DNS
paths:
  /mcp:
    post:
      operationId: callMcpTool
      summary: Chama uma ferramenta do MCP
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                method: {type: string, example: "tools/call"}
                params: {type: object}
                id: {type: integer, example: 1}
      responses:
        '200':
          description: Sucesso

🐳 Docker

本项目已准备好在容器中运行。

1. 构建镜像

在本地生成 Docker 镜像:

docker build -t mcp-simple-server .

2. 启动容器 (Docker Compose)

推荐的运行方式是使用随附的 docker-compose.yml,它配置了网络和环境变量:

docker compose up -d

容器将以 mcp-simple-server 名称创建,并可在 3030 端口访问。

3. 检查状态和日志

# Ver se o container está rodando
docker ps | grep mcp-simple-server

# Ver logs do servidor
docker compose logs -f

🛠️ 开发

要在本地运行服务器:

cd ~/apps/mcp-simple-server
npm install
node server.js

服务器将在 http://localhost:3030 监听。

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables remote access to the MemPalace MCP server via HTTP, supporting bearer token authentication and concurrent clients while exposing all mempalace tools.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Lifts local stdio MCP servers into remote Streamable HTTP endpoints for cloud-hosted AI clients, with bearer-token auth and tool policy filtering.
    9 npm
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Converts any MCP server into simple HTTP endpoints, enabling AI agents that only support HTTP (like ChatGPT Custom GPT or web_fetch) to use MCP tools.
    -