Skip to main content
Glama

NovaForge MCP Server

零第三方依赖的 MCP(Model Context Protocol)服务端,用 Python 标准库实现,离线可跑。 一份固定 JSON 配置即可被主流 AI 客户端接入:让 AI 在沙箱工作区里写代码、生成脚手架、跑白名单构建命令、检索项目文档,并通过 Home Assistant 读写设备状态。

为什么不用官方 SDK

官方 Python SDK 依赖 httpx / uvicorn / starlette 等第三方包,在离线或 DNS 受限环境里装不上。 本仓库只用标准库实现握手、工具列表、工具调用与两种传输,pip install 之外零外部依赖,拷走就能跑。

Related MCP server: my-pi

特性

能力

说明

双传输

stdio(桌面客户端首选)与 Streamable HTTP(POST /mcp,远程 / 容器 / 网关)

12 个工具

工作区读写、脚手架、白名单命令、HA 设备读写、文档全文检索、官方技能库

路径沙箱

所有文件操作 resolve 后必须落在工作区内,../ 逃逸直接拒绝

敏感路径拦截

.ssh .gnupg .aws .kube .git .svn .env credentials secrets 等一律拒写

命令白名单

code.run 默认关闭,开启后首个 token 必须命中白名单

输出脱敏

命令输出里含 password/token=/api_key 的行整体替换为 <redacted line>

可选鉴权

HTTP 传输支持 NOVAFORGE_MCP_TOKEN Bearer 校验

可自检

--describe 打印能力清单,tests/smoke_test.py 覆盖 stdio 与 HTTP 全链路

安装

git clone https://github.com/231ljk/novaforge-mcp.git
cd novaforge-mcp
python -m pip install -e .          # 可选,装完可直接用 novaforge-mcp 命令

不想装包也行,把仓库目录加进 PYTHONPATH,按 python -m novaforge_mcp 启动即可。

启动

# 桌面客户端(Claude Code / Claude Desktop / Cursor / Marvis ...)
python -m novaforge_mcp --transport stdio --workspace "D:\NovaForge"

# 局域网 / 远程 / 容器
python -m novaforge_mcp --transport http --host 0.0.0.0 --port 8737 --workspace "D:\NovaForge"

# 两种一起开(同一进程内 stdio + HTTP)
python -m novaforge_mcp --transport both

# 自检:打印服务端能力与工具清单
python -m novaforge_mcp --describe

# 版本
python -m novaforge_mcp --version

HTTP 模式路由:

方法

路径

用途

POST

/mcp

JSON-RPC 请求(单条或批量);通知类消息返回 202

GET

/health

健康检查,返回服务名、版本、工具数与工作区

GET

/mcp

返回 405,提示改用 POST(本服务端为无状态实现,不需要 SSE 长连接)

DELETE

/mcp

返回 204,会话终止空操作

固定配置(全客户端通用)

下面这份就是"复制即用"的标准形态。只有两个值需要改:PYTHONPATH 指向本仓库目录,NOVAFORGE_MCP_WORKSPACE 指向 AI 可读写的工作区。

{
  "mcpServers": {
    "novaforge": {
      "command": "python",
      "args": ["-m", "novaforge_mcp", "--transport", "stdio"],
      "env": {
        "PYTHONPATH": "D:\\tools\\novaforge-mcp",
        "NOVAFORGE_MCP_WORKSPACE": "D:\\NovaForge",
        "NOVAFORGE_MCP_ALLOW_EXEC": "1"
      }
    }
  }
}

占位符

含义

注意

D:\\tools\\novaforge-mcp

本仓库克隆到本机后的目录(含 novaforge_mcp/ 包)

已 pip install 时可删掉这一行

D:\\NovaForge

工作区沙箱根目录

所有文件工具都被限制在这里

NOVAFORGE_SKILLS_DIR

官方技能库根目录(默认取仓库内 skills/)

NOVAFORGE_MCP_ALLOW_EXEC

1 允许白名单命令执行,默认 0

不跑构建就填 0

command: "python"

解释器

不在 PATH 时写绝对路径,如 C:\\...\\python.exe

Windows 的 JSON 里反斜杠要写两个 \\;macOS / Linux 用 /。

各客户端配置

1. Claude Code

项目级配置:在仓库根目录建 .mcp.json,内容就是上面那份固定配置。

或者用 CLI 一条命令注册:

claude mcp add novaforge -- python -m novaforge_mcp --transport stdio
claude mcp list                     # 验证是否连上

带环境变量:

claude mcp add novaforge \
  --env PYTHONPATH=D:/tools/novaforge-mcp \
  --env NOVAFORGE_MCP_WORKSPACE=D:/NovaForge \
  -- python -m novaforge_mcp --transport stdio

远程 HTTP 模式:

claude mcp add --transport http novaforge http://127.0.0.1:8737/mcp

Windows 上如果 command 是 npx / uvx 这类 .cmd 脚本,需要用 cmd /c 包一层;本服务端直接用 python.exe,不受这个限制。

2. Claude Desktop

编辑配置文件:

  • Windows:%APPDATA%\Claude\claude_desktop_config.json

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

把上面的 mcpServers 整段贴进去,保存后完全退出(托盘里也退)再重开。 在对话框的工具图标里能看到 novaforge 及其 12 个工具即接入成功。

3. Cursor

  • 全局:~/.cursor/mcp.json

  • 项目级:<项目>/.cursor/mcp.json

同样使用 mcpServers 结构。改完在 Settings → MCP 里刷新,工具列表出现 novaforge 即可。

4. VS Code 系插件(Cline / Roo Code)

在插件的 cline_mcp_settings.json 里加同一段 mcpServers,保存后插件自动重启连接。

5. ChatGPT(远程连接器)

ChatGPT 只接受公网可达的远程 MCP(Streamable HTTP),不能直连本机 127.0.0.1。做法:

  1. 本机起 HTTP 传输:python -m novaforge_mcp --transport http --host 0.0.0.0 --port 8737

  2. 用隧道把它暴露成 HTTPS 域名,例如 cloudflared tunnel --url http://127.0.0.1:8737、ngrok http 8737 或 frp

  3. ChatGPT → 设置 → 连接器(需开发者模式)→ 新建连接器,URL 填 https://<你的域名>/mcp

  4. 认证方式:公开演示选"无认证",需要保护时设 NOVAFORGE_MCP_TOKEN 并选 Bearer / API Key

  5. 回到对话,在工具里挂上该连接器

公网暴露时务必设 NOVAFORGE_MCP_TOKEN,否则任何拿到 URL 的人都能调用你的工作区工具。

6. 豆包 及国内同类客户端

豆包 App / 网页版目前没有面向用户的自定义 MCP 入口,不能直接填 URL 或命令。 可行路径是借支持 MCP 的宿主客户端(Trae、Cherry Studio、Cline 等)接入本服务端,模型侧继续选豆包系列;配置仍是同一份 mcpServers JSON。 若宿主只支持远程 URL,用 --transport http 起服务后填 http://127.0.0.1:8737/mcp。

7. Marvis(腾讯 Marvis)

Marvis 用显式 config 注册私有服务端,等价写法:

{
  "name": "novaforge-mcp",
  "command": "C:\\Users\\<你>\\AppData\\Local\\Programs\\Python\\Python313\\python.exe",
  "args": ["-m", "novaforge_mcp", "--transport", "stdio"],
  "cwd": "D:\\tools\\novaforge-mcp",
  "env": {
    "PYTHONPATH": "D:\\tools\\novaforge-mcp",
    "NOVAFORGE_MCP_WORKSPACE": "D:\\NovaForge",
    "NOVAFORGE_MCP_ALLOW_EXEC": "1"
  }
}

注册后状态应为 authenticated,tools/list 返回 12 个工具。 cwd 与 PYTHONPATH 都指向仓库目录,是因为 python -m 需要在 sys.path 上找到 novaforge_mcp 包。

8. 微信开发者工具(AI 助手)

微信开发者工具 2.x 起自身就是 MCP 客户端(内建服务端名为 wechat-devtools,自定义服务端不要重名)。接入流程:

  1. 在工具的 AI / MCP 设置里添加自定义服务端(具体入口以当前版本界面为准)

  2. 类型选 stdio,命令填本机 python.exe 绝对路径,参数 -m novaforge_mcp --transport stdio

  3. 环境变量填 PYTHONPATH、NOVAFORGE_MCP_WORKSPACE

  4. 服务端名填 novaforge,保存后在 AI 面板确认工具可用

小程序项目里也可以直接把固定配置写进项目的 MCP 配置文件(如有该入口),JSON 结构与上面完全一致。

9. 其它客户端 / 自研 agent

只要支持 MCP,就二选一:stdio 用上面的 command + args + env;远程用 http://<host>:<port>/mcp。 自研客户端可直接发 JSON-RPC:

curl -s http://127.0.0.1:8737/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

官方技能库

仓库里的 skills/ 是官方自创技能集合,面向所有 AI:只要客户端能连 MCP,就能用上技能,不要求客户端原生支持 Skills。

技能

用途

novaforge-mcp-server

开发与扩展 MCP 服务端:工具契约、双传输、沙箱、白名单、冒烟测试

novaforge-ha-integration

Home Assistant 自定义集成:config flow、coordinator、实体映射、HACS

novaforge-esp32-firmware

ESP32 固件:PlatformIO、mDNS 发现、直连、OTA、烧录排障

novaforge-android-build

安卓构建与签名:Chaquopy 打包、内存降配、lint 关闭、apksigner

novaforge-site-maintain

官网维护:新增页面、导航同步、下载直链、Pages 部署核验

novaforge-client-setup

9 类 AI 客户端的接入配置与排错

novaforge-brand

品牌与文案规范:配色、字体、语气、页面结构

调用方式:

{"name": "skill.list",   "arguments": {}}
{"name": "skill.get",    "arguments": {"name": "novaforge-esp32-firmware"}}
{"name": "skill.search", "arguments": {"query": "OTA", "limit": 10}}

也可走 resources:resources/list 返回 skill://<name>/SKILL.md,resources/read 取正文,只支持资源的客户端同样可用。

原生支持技能的客户端(Claude Code / Claude Desktop)可直接把 skills/<name>/ 复制到 ~/.claude/skills/,或用 NOVAFORGE_SKILLS_DIR 指向本仓库的 skills/。技能体例见 skills/README.md。

工具清单

工具

作用

关键参数

workspace.list

列出工作区文件

path、max_entries(≤1000)

code.write

新建 / 覆盖文本文件

path、content、overwrite

code.scaffold

生成项目骨架

name、template(python-cli / ha-integration / mcp-server)、path

code.run

跑白名单构建 / 测试命令

command、timeout(≤600);需 ALLOW_EXEC=1

device.list

列出 HA 桥接的实体

domain(light / switch / sensor ...)

device.state

读单个实体状态与属性

entity_id

device.set

开关 / 亮度控制

entity_id、action(on / off / toggle / level)、value

ha.call_service

调任意 HA 服务

domain、service、data

kb.search

工作区文档与源码全文检索

query、path、limit(≤50)

skill.list

列出官方技能库

query、tag

skill.get

读取某个技能的完整正文

name、path、max_chars

skill.search

在全部技能正文里检索

query(≥2 字符)、limit(≤50)

skill.list

列出官方技能库

query、tag

skill.get

读取某个技能的完整正文

name、path、max_chars

skill.search

在全部技能正文里检索

query(≥2 字符)、limit(≤50)

环境变量

变量

默认

说明

NOVAFORGE_MCP_WORKSPACE

当前工作目录

文件工具沙箱根

NOVAFORGE_MCP_ALLOW_EXEC

0

1 允许 code.run 白名单命令

NOVAFORGE_MCP_ALLOW_DEVICE_WRITE

1

0 时 device.set / ha.call_service 只读拒绝

NOVAFORGE_HA_URL

空

Home Assistant 地址,如 http://homeassistant.local:8123

NOVAFORGE_HA_TOKEN

空

HA 长期访问令牌

NOVAFORGE_MCP_HOST

127.0.0.1

HTTP 监听地址

NOVAFORGE_MCP_PORT

8737

HTTP 监听端口

NOVAFORGE_MCP_TOKEN

空

HTTP 传输的 Bearer 令牌,公网暴露时必须设

命令白名单:python python3 py pip node npm npx git pytest gradle gradlew java javac adb cmake make esptool.py platformio。 Windows 绝对路径会先取文件名、去掉 .exe 再比对白名单。

安全模型

  • 沙箱优先:resolve(strict=False) 后校验目标是否在工作区内,逃逸即报错;../ 不做字符串拼接绕过。

  • 敏感段拦截:路径任一段命中敏感名(.ssh、.env、credentials ...)直接拒;

  • 写盘上限 2 MB(MAX_WRITE_BYTES),输出上限 20000 字符并附截断标记。

  • 危险能力默认关:命令执行默认关闭;设备写可单独关闭;HA 未配置时明确报错而不是假装成功。

  • 公网暴露前:设 NOVAFORGE_MCP_TOKEN,并放在反代后面做 HTTPS。

目录结构

novaforge-mcp/
├─ novaforge_mcp/
│  ├─ __main__.py      # CLI 入口:--transport / --host / --port / --workspace / --describe
│  ├─ protocol.py      # JSON-RPC 2.0 与 MCP 方法分发
│  ├─ transports.py    # stdio 行式 JSON + ThreadingHTTPServer
│  ├─ tool_specs.py    # 12 个工具的 JSON Schema
│  ├─ skills.py        # 官方技能库:发现、读取、检索
│  ├─ tools.py         # 工具实现
│  ├─ security.py      # 路径沙箱、脱敏、截断
│  └─ config.py        # 环境变量配置
├─ examples/           # 各客户端可直接复制的配置
├─ tests/smoke_test.py # stdio + HTTP 冒烟测试
└─ server.json         # MCP Registry 清单(待 PyPI 发布后可用)

测试

python tests/smoke_test.py

覆盖:握手、tools/list、通知不回复、ping、code.write 落盘、workspace.list 可见、../ 逃逸拒绝、敏感路径拒绝、code.run 默认阻断、HA 未配置报错、未知方法报错、GET /health、POST /mcp、通知返回 202、未知路由 404。

许可

MIT,见 LICENSE。

Available Tools

12 tools
code.runC

Run an allowlisted build/test command inside the workspace (requires NOVAFORGE_MCP_ALLOW_EXEC=1).

Inputs: command (required), timeout.

code.scaffoldC

Generate a project skeleton. Templates: python-cli, ha-integration, mcp-server.

Inputs: name (required), path, template.

code.writeB

Create or overwrite a text file inside the workspace sandbox.

Inputs: path (required), content (required), overwrite.

device.listC

List smart-home entities bridged through Home Assistant.

Inputs: domain.

device.setC

Turn a device on/off/toggle or set brightness level.

Inputs: action (required), entity_id (required), value.

device.stateC

Read current state and attributes of one entity.

Inputs: entity_id (required).

ha.call_serviceC

Call any Home Assistant service (escape hatch for advanced automation).

Inputs: domain (required), service (required), data.

kb.searchB

Full-text search across project docs and source files in the workspace.

Inputs: query (required), path, limit.

skill.getA

Load the full Markdown instructions of one official skill. Returns the SKILL.md body plus the list of bundled files, so any AI client can follow the procedure.

Inputs: name (required), path, max_chars.

skill.listC

List the official NovaForge skill library: curated procedures for firmware, Home Assistant, MCP servers, Android builds, site maintenance and client setup.

Inputs: tag, query.

skill.searchB

Full-text search across all official skill bodies; returns matching lines with skill name and line number.

Inputs: query (required), limit.

workspace.listC

List files and folders inside the NovaForge workspace sandbox.

Inputs: path, max_entries.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools map to distinct resource+action pairs across three clear namespaces (workspace/code, device, skill/kb). Two mild overlaps exist: kb.search vs skill.search (workspace docs vs official skill bodies) and device.set vs ha.call_service, which can also drive devices, but the descriptions frame the latter as an advanced escape hatch so an agent can reasonably choose.

    Naming Consistency4/5

    Names follow a predictable namespace.action pattern (workspace.list, code.write, device.set, skill.get) with action verbs used consistently. The one deviation is ha.call_service, which uses a snake_case verb instead of the simple action style; its namespace also splits Home Assistant concerns across 'device' and 'ha' prefixes.

    Tool Count5/5

    12 tools is well within the ideal 3-15 range and each is scoped to a clear job across the three sub-domains (workspace/codegen, smart home, skills). No tool feels redundant or purely decorative.

    Completeness3/5

    The surface is notably missing a file-read operation: you can list files, write files and scaffold, but there is no way to read back an arbitrary workspace file except through kb.search snippets, which will cause agent dead ends when editing existing code. Smart-home control and the read-only skill library look reasonably complete for their scope, though file delete/move/read are absent.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Gives any MCP-compatible AI chat or agent a safe, model-neutral coding runtime with file read/search, structured multi-file patches, command execution, interactive sessions, and git operations, all confined to a single workspace and gated by permission modes.
      Apache 2.0
    • A
      license
      C
      quality
      B
      maintenance
      Local-first MCP runtime for coding agents with bounded workspace access, content-preconditioned writes, AST search, LSP navigation and diagnostics, and Git status/diff. Designed to give coding agents useful repository access without treating unrestricted shell access as the default integration boundary.
      13
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables any MCP-compatible AI, whether in the browser or running locally, to create and edit projects, run terminal commands and long-running jobs, and optionally use Docker, all guarded by a policy engine, workspace jail, authentication, and audit logging.
      23
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables LLM agents to perform local development and automation over MCP STDIO, including project context retrieval, file read/write and patching, shell/Python execution, Git inspection, work-state tracking, and validation. It runs as a local Python process with Dev and Safe execution modes and audit logging for trusted single-developer environments.
      16
      Apache 2.0