Skip to main content

把一个本地项目作为 token 保护的 MCP 服务暴露给 ChatGPT。

Project description

Project MCP

把一个本地项目作为 token 保护的 MCP 服务暴露给 ChatGPT。

Project MCP 故意保持很小:

  • 一个本地项目根目录
  • 一个固定项目 token
  • 一个 Streamable HTTP MCP 端点:/mcp
  • 通过 Cloudflare quick tunnel 暴露公网 HTTPS
  • 不做登录、不做托管 relay、不做 ChatGPT 自定义 UI 卡片

快速开始

不安装,直接运行:

uvx project-mcp

或安装成持久 CLI:

uv tool install project-mcp
project-mcp

默认会把当前目录作为项目目录,并输出 ChatGPT 需要粘贴的 Server URL,例如:

https://example.trycloudflare.com/mcp?project_mcp_token=pmcp_...

如果保存的本地端口被占用,start 会自动换一个空闲端口继续启动;公网 tunnel URL 不受影响。 Cloudflare quick tunnel 的 *.trycloudflare.com Host 会被默认允许,其他公网 Host 默认拒绝。

在 ChatGPT Developer Mode 里创建 app/connector:

Connection: Server URL
Authentication: None / No Authentication

命令

project-mcp
project-mcp --root /path/to/project
project-mcp --read-only
project-mcp --no-bash
project-mcp setup --root . --port 8080
project-mcp start --root .
project-mcp doctor
project-mcp token rotate
project-mcp settings show

项目配置保存在仓库外:

~/.project-mcp/workspaces/<sha256-realpath>.json

token 按“设备 + 项目根目录”固定保存,直到你显式轮换它。

MCP 工具

Project MCP 暴露:

  • server_config
  • workspace_info
  • tree
  • search
  • grep
  • read_file
  • write_file
  • edit_file
  • show_changes
  • run_check

--read-only 会隐藏 write_fileedit_file--no-bash 会隐藏 run_check

grepsearch 的安全别名,方便 ChatGPT 按直觉查代码;它不会执行 shell grep,仍然遵守项目 root、blocked globs、二进制拒绝和结果数量限制。

run_check 默认使用安全白名单,覆盖 codexpro 风格的只读/验证命令,并额外支持更多常见检查器:

  • pwdlsfind
  • git statusgit diffgit loggit showgit branchgit rev-parsegit ls-files
  • pytestpython -m pytestpython -m unittestuv run pytest
  • npm/pnpm/yarn/bun test|lint|typecheck|build|check|validate
  • npm/pnpm/yarn/bun run build:clientsbun run smoke:network-propagation 这类带冒号后缀的检查/验证脚本
  • bun --filter @scope/pkg smoke:case-name 这类 Bun monorepo 定向验证脚本
  • go testcargo test/check/clippy
  • tsceslintbiome checkprettier --check
  • ruff checkruff format --checkmypypyrightbasedpyright

危险命令和参数仍会被拦截,例如 rmcurlgit push--fix--writefind -delete、管道和重定向。

Project MCP 默认不会屏蔽 .tmp/.pi/data/ 这类项目运行目录,因为它们可能是理解项目状态所必需的上下文。若某个项目希望减少噪音,可以通过 PROJECT_MCP_BLOCKED_GLOBS 追加自己的排除规则。

开发

uv sync
uv run ruff check .
uv run pytest
uv build
uv publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_mcp-0.1.7.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

project_mcp-0.1.7-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file project_mcp-0.1.7.tar.gz.

File metadata

  • Download URL: project_mcp-0.1.7.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for project_mcp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 96641a98606bb0b74dfdfb070a25996661d5aed33b6a4375b4fd067701682792
MD5 f27185748b3ad617516e4c769b3c084a
BLAKE2b-256 edb12b5ebf811d7f3a520c52228de64c2f850b2de126981282d5be7d789451b3

See more details on using hashes here.

File details

Details for the file project_mcp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: project_mcp-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for project_mcp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9906e4d383f4a02e548d4b642e6d7d4a7f39403aade756b73cad0e2f00a7e2c2
MD5 3634846558827c63ddc502c4cb3e2832
BLAKE2b-256 dd8803b28f1ed69c40eff3ef7ef8e8cfc4c4742b3724722806539506e396e567

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page