Tctc Mcp

io.github.kofujimura由 GitHub 账号 kofujimura 发布v0.3.3更新于 Nov 3, 2026

ERC-7303 token-controlled roles for AI agents: grant, check, and revoke permissions on-chain

概览

AI 生成的概览

把 ERC-7303 的代币控制角色暴露给 AI 代理,让代理查询自身链上权限,并由发行方授予或撤销权限。

可以做什么
  • 列出已配置的角色及其控制代币
  • 查询某账户是否持有角色,附带实时余额证据,并在会话开始时评估全部角色
  • 内省任意 ERC-7303 合约,无需预先配置即可发现其角色结构
  • 把 ERC-8004 代理编号解析为所有者、代理 URI、代理钱包和代币绑定账户
  • 通过铸造控制代币授予角色(可带到期时间),并通过销毁代币撤销角色
适用场景
适合需要代理在执行操作前自行核验链上权限的场景,也适合人类主体希望用代币铸造与销毁来发放和收回代理能力、而不依赖权限服务器的场景。
运行要求
通过 npx 从 npm 包 tctc-mcp 在本机运行,需提供 JSON 配置文件。只读模式只需含 RPC 端点的配置;管理模式还需在环境变量 TCTC_ADMIN_PRIVATE_KEY 中提供发行方密钥。需要能访问以太坊 RPC 的网络连接。
安装前请注意
管理模式需要在 TCTC_ADMIN_PRIVATE_KEY 中提供发行方私钥,该密钥可铸造和销毁角色代币;不要写入配置文件,含疑似私钥的配置会在启动时被拒绝。授予与撤销工具会发送链上交易,消耗手续费并改变权限,撤销即为即时熔断。角色查询与发现会通过配置的 RPC 提供方读取公开链上状态。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Tctc Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

tctc-mcp

[npm version]

An MCP server exposing ERC-7303 (Token-Controlled Token Circulation) roles to AI agents: agents check their own on-chain permissions, and human principals grant/revoke them by minting/burning control tokens — no permission server required.

Status: v0.3.4 — adds timed roles with gasless auto-expiry (below), on top of v0.2's IERC7303 auto-discovery; published on npm (tctc-mcp), unit-tested and verified end-to-end against the Sepolia demo deployment (grant → check → revoke → check, and grant-for-75s → auto-expiry, through a real MCP client).

Demo (60 seconds)

[Watch the 60-second demo video]

A human grants an AI agent a minting permission; the agent verifies it on-chain and mints an NFT. The human burns the role token — and the agent instantly loses the capability. Live on Sepolia, no permission server involved.

Quick start

The package is published on npm, so no clone or build is needed — npx fetches and runs it directly:

bash
# 1. Get a config. The secret-free Sepolia demo config needs no API keys:curl -fsSLO https://raw.githubusercontent.com/kofujimura/tctc-mcp/main/examples/config.sepolia.agent.json
# 2. Register with your MCP client, e.g. Claude Code#    (read-only mode: only query tools are registered)claude mcp add tctc -- npx -y tctc-mcp --config "$PWD/config.sepolia.agent.json"
# Admin mode (principal side): grant_role / revoke_role also registered.# Provide the issuer key ONLY via the environment:claude mcp add tctc-admin --env TCTC_ADMIN_PRIVATE_KEY=0x... \  -- npx -y tctc-mcp --config "$PWD/config.sepolia.json"

Or in a project-scoped .mcp.json:

json
{ "mcpServers": { "tctc": { "command": "npx",    "args": ["-y", "tctc-mcp", "--config", "examples/config.sepolia.agent.json"] } } }

A fuller registration example is in examples/claude.mcp.json. The admin private key is only ever read from the TCTC_ADMIN_PRIVATE_KEY environment variable; configs containing anything that looks like a private key are rejected at startup.

Using tctc-mcp from your own app

The only supported entry point is the tctc-mcp bin — spawn it via npx --no-install tctc-mcp (or node_modules/.bin/tctc-mcp). Never reference the package's dist/ files directly: they are internal, their layout is unversioned, and the package's exports field refuses deep imports. A minimal MCP-SDK client example (the pattern for a web backend) is in examples/client-stdio.mjs; the release pipeline verifies the packed bin end-to-end (scripts/verify-pack.mjs).

Web application starter

Want to see tctc-mcp protecting a real API route?

tctc-openai-starter is a standalone Next.js starter that verifies wallet ownership with Sign-In with Ethereum, checks the configured role through tctc-mcp, and calls OpenAI only when the on-chain gate grants access.

Use it as a GitHub template.

Token-gating any MCP server: tctc-gate

The reverse direction lives in this repo too: tctc-gate (npm) is a transparent stdio proxy that puts an ERC-7303 role check in front of any existing MCP server, unmodified — deny comes back with a grant URL that opens the dashboard pre-filled. tctc-mcp lets agents ask about roles; tctc-gate enforces them at the boundary:

sh
npx -y tctc-gate --config gate.json -- npx -y some-mcp-server …

Tools

ToolModePurpose
list_rolesbothConfigured roles and their control tokens
check_rolebothDoes an account hold a role? (live balanceOf, with evidence)
check_all_rolesbothSession-start self-assessment across all roles
discover_rolesbothIntrospect any contract via IERC7303 — no role config needed
resolve_agentboth*ERC-8004 agentId → owner / agentURI / agentWallet / ERC-6551 TBA
grant_roleadminMint the control token to a subject
revoke_roleadminBurn the subject's control token — the kill switch

* registered only when the config has an identity section.

Subjects can be given as a raw address, as an ERC-8004 agentId (resolved to its ERC-6551 Token Bound Account, the recommended binding target), or omitted to use the config's self.

IERC7303 auto-discovery (v0.2)

ERC-7303 now defines an introspection interface (ethereum/ERCs#1872, merged 2026-07-11): compliant contracts expose hasRole, control-token getters, configuration events, and ERC-165 detection (interfaceId 0x4ee69337). tctc-mcp uses it two ways:

  • target roles — a role config names only the target contract; the server reads which control tokens gate the role from the contract itself, and the verdict is the target's own hasRole() answer:

    json
    "roles": { "MINTER_ROLE": {    "target": { "address": "0x4C0a78803D47154B9C6F42EC4AEbab2D1C94c97D" } } }
  • discover_roles — introspect any address at run time, with no role configuration at all. Non-compliant contracts report supportsIERC7303: false; static controlTokens configs remain the fallback for pre-IERC7303 deployments.

Working example: examples/config.sepolia.discovery.json (secret-free, public RPC), verified live by scripts/e2e-discovery.mjs.

Timed roles: gasless auto-expiry (v0.3)

Delegation to an agent is usually short-term — "mint for one hour", "act for the duration of this task". With an expiring control token (ExpiringControlTokens), balanceOf() returns 0 once the holder's expiry passes, so the role revokes by itself, with no transaction — even if the principal forgets, goes offline, or loses keys. The ERC-7303 target contract needs no changes at all (the Sepolia expiry demo target is a byte-for-byte copy of TCTCDemoToken).

  • Granting: a role whose grant template has $expiresAt requires an expiry — grant_role with expiresInSeconds: 3600 is "grant MINTER_ROLE for one hour":

    json
    "admin": { "grant": { "function": "mint(address,uint256,uint64)",                      "args": ["$subject", "$typeId", "$expiresAt"] } }
  • Checking: check_role evidence reports expiresAt (unix seconds) when the control token exposes it, so an agent can self-report "this permission expires in 5 minutes".

  • Kill switch unchanged: expiry is a fail-safe, not a replacement — revoke_role (issuer burn) still revokes immediately within the validity window.

Working example: the TIMED_MINTER_ROLE in examples/config.sepolia.json, verified live by scripts/e2e-expiry.mjs (grant for 75 s → watch it expire with no further transaction).

Human dashboard

Live: https://tctc-mcp.vercel.app/ — while tctc-mcp exposes ERC-7303 roles to AI agents, the TCTC Dashboard exposes the same on-chain state to the humans who manage them: inspect any IERC7303 target, watch hasRole verdicts and per-control-token balanceOf evidence live, grant/revoke as the issuer (with timed grants and countdowns for expiring control tokens), and deploy new control-token collections straight from a browser wallet. Two clients of one source of truth: the chain. See dashboard/README.md for details and try-it links.

[TCTC Dashboard — inspecting a target's roles, with live hasRole verdicts and issuer grant/revoke controls]

Not just for AI-agent delegation: any ERC-7303 contract works, so the dashboard doubles as a general-purpose on-chain permission manager — issue certificate collections, grant and revoke roles, and audit who holds what, all from a browser wallet.

Documents

  • docs/CONCEPT.md — background and rationale: TCTC as the authorization layer for AI agents, its relationship to ERC-8004 (Trustless Agents) and ERC-6551 (Token Bound Accounts), recommended ERC-7303 spec updates, and the adoption strategy.
  • docs/MCP_SERVER_SPEC.md — v1 design specification (architecture, config, tools, security, roadmap).
  • docs/ERC_DRAFT_EXPIRABLE_1155.md — working draft of a planned ERC, "Expirable ERC-1155 Tokens": the standard behind the timed roles above (per-holder expiry, time-aware balanceOf, expiresAt/ExpiryUpdated, interface ID 0x300e616b). Not yet submitted to ethereum/ERCs; feedback welcome.
  • docs/TEST_REPORT.md — v1 test report: 24 unit tests and the live Sepolia E2E (on-chain kill-switch cycle through a real MCP client).
  • examples/config.sepolia.json — concrete config for the Sepolia demo deployment (primary roles, static bindings) and the TCTC repo's MyComplexToken sample (COMPLEX_* roles, resolved via IERC7303 target discovery).
  • examples/config.sepolia.agent.json — secret-free agent-side config for the same demo deployment (public RPC, no API keys); the one used in the Quick start above.
  • examples/config.sepolia.discovery.json — IERC7303 auto-discovery variant: no control tokens configured, the target contract explains its own role structure.
  • examples/contracts/ — sources of the demo contracts deployed on Sepolia (AgentControlTokens, TCTCDemoToken, ERC7303, IERC7303).

Demo deployment (Sepolia, Etherscan-verified)

Development

bash
git clone https://github.com/kofujimura/tctc-mcp.git && cd tctc-mcpnpm install && npm run buildnode dist/index.js --config examples/config.sepolia.agent.json
npm test                  # unit tests (vitest)node scripts/e2e-live.mjs # live E2E: spawns the server via MCP stdio client                          # (needs ALCHEMY_API_KEY; admin phase additionally                          #  TCTC_ADMIN_PRIVATE_KEY and E2E_SUBJECT)

Related

来源:README.md,提交 47baaf8

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.3最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。