tgmcp #
A Tangled MCP server using FastMCP, Pydantic, and the tg CLI.
Run #
nix run .#tgmcp from the repository root starts the stdio server with tg, Git, and SSH included.
From mcp/, run uv run tgmcp with tg on your PATH.
Log in with tg auth login <handle> before using authenticated tools.
Point your MCP client at the checkout:
{
"mcpServers": {
"tangled": {
"command": "nix",
"args": ["run", "/path/to/tg#tgmcp"]
}
}
}
Configuration #
| Variable | Purpose |
|---|---|
TGMCP_EXECUTABLE |
Override the tg executable |
TGMCP_ACCOUNT |
Override tg's active account |
TGMCP_CONFIG |
Override tg's config path |
TGMCP_TIMEOUT_SECONDS |
Command timeout, defaults to 30 seconds |
The server inherits tg's environment and credentials. Local Git tools need absolute paths on the server's filesystem.
New-stack behavior #
The server targets tg's new Tangled protocols. edit_issue,
edit_pull_request, and update_pull_request require repo so record keys
are resolved in the correct repository. PR creation and updates require
published source commits and never push automatically.
Mutation results can include warnings after a saved change. Do not repeat the
mutation to repair a pending attestation. Use list_pending_attestations and
retry_pending_attestations instead. Social writes to unupgraded knots are
rejected.
create_repo and edit_repo accept contribution_policy as anyone,
members, or collaborators. Omission preserves the knot's policy.
The server inherits TG_APPVIEW and TG_FOSTER_KNOT from tg's configuration.
Development #
Enter nix develop from the repository root, then cd mcp and run uv sync.
nix build .#tgmcpbuilds the package from the repository root.nix fmtformats the code from the repository root.uv run pytestruns local tests with a faketg, without an account or network.uv run fastmcp dev inspectoropens MCP Inspector.
approve_pipeline releases blocked workflows. retry_pipeline reruns the stored
specification and accepts an optional workflow selection. cancel_pipeline also
cancels blocked workflows. trigger_pipeline accepts full 40- or 64-character
commit hashes without a working directory. Its result preserves every scheduled
ID in pipelines and the server's message. The existing pipeline field
contains the first ID, or an empty string when none were scheduled. Log control
events preserve the step's outcome. An unconfirmed stream closure produces an
error result with the events already collected.
Existing issue and PR edit, close, and reopen tools accept expected_cid.
Read the cid from the corresponding view to reject stale changes. Results
retain their existing fields and add record references when available. Fork
results include importStatus and importReason; check warnings before retrying
an import that already created a repository.