# Tileward in Claude Code How to add Tileward Context to Claude Code as an MCP server and Tileward Governance as a `UserPromptSubmit` hook that runs before the model, how to make that hook an organisation-wide control with managed settings, and what happens when Tileward is unreachable. Context takes a sign-in or an API key; Governance takes a key, because the policy is bound to it. Page: https://tileward.com/docs/claude-code/ ## Tileward Context: recall instead of resend Context is hosted: the history lives on Tileward's side, and each turn asks for the part that answers the question. Add it with an API key in one command: ``` claude mcp add --transport http tileward-context https://context.tileward.com \ --header "Authorization: Bearer $TILEWARD_API_KEY" ``` Restart, then `/mcp` lists the tools. Ask the model to remember something, start a new thread, and ask it to recall. Or sign in instead of pasting a key. Claude Code opens your browser, you sign in, and it keeps a token of its own; you can disconnect the device from Context → Connected apps in the console. ``` claude mcp add --transport http tileward-context https://context.tileward.com/mcp/connect claude mcp login tileward-context ``` - Use the key in CI, in a container or on a headless box, or when one credential should also carry the Governance hook: a sign-in cannot carry a topic policy. - Each remember and recall carries a `conversation` argument that the model fills in, so one thread's material stays out of another's. For a boundary that does not depend on the model, give each project its own key. ## Tileward Governance: a gate, not a system prompt Claude Code runs a `UserPromptSubmit` hook before the model sees a prompt and honours its refusal. A refused prompt costs no generation tokens. The gate ships as a plugin: ``` claude plugin marketplace add Tileward-com/tileward-claude-marketplace claude plugin install tileward-guard@tileward export TILEWARD_API_KEY=tw_live_... ``` - The plugin registers a small script that runs before each prompt and refuses on the policy bound to your key. `/hooks` in a session shows it loaded. - Bind a policy to the key first, in the console under Settings → API keys. A key with no policy refuses nothing. ### Without installing anything You can point the hook at Tileward directly and deploy nothing. Claude Code lets a prompt through when it cannot reach an HTTP hook, so this shape suits a setup that can tolerate an outage. ``` // .claude/settings.json { "hooks": { "UserPromptSubmit": [{ "matcher": "", "hooks": [{ "type": "http", "url": "https://api.tileward.com/v1/guard/hook", "headers": { "Authorization": "Bearer $TILEWARD_API_KEY" }, "allowedEnvVars": ["TILEWARD_API_KEY"], "timeout": 10 }] }] } } ``` The address is `/v1/guard/hook`, which answers in the shape Claude Code's hooks expect. The plain `/v1/guard` on the endpoint table is the same guard, for calling from your own code. ## For an organisation: a control, not a guardrail Managed settings apply to everyone, and a user cannot override them. ``` // managed-settings.json { "extraKnownMarketplaces": { "tileward": { "source": { "source": "github", "repo": "Tileward-com/tileward-claude-marketplace" } } }, "enabledPlugins": { "tileward-guard@tileward": true }, "allowManagedHooksOnly": true, "strictKnownMarketplaces": true, "disableSideloadFlags": true } ``` Each line closes a specific door, and dropping any one turns enforcement back into a suggestion: - `enabledPlugins` force-enables the plugin, so a user cannot uninstall it. - `allowManagedHooksOnly` loads only managed hooks and force-enabled plugins, so a developer cannot unhook themselves. - `strictKnownMarketplaces` stops users adding their own sources. - `disableSideloadFlags` rejects the command-line flags that would bypass both for a single run. Managed settings live at `/Library/Application Support/ClaudeCode/managed-settings.json` on macOS, `/etc/claude-code/managed-settings.json` on Linux and `C:\Program Files\ClaudeCode\managed-settings.json` on Windows, or are pushed from the claude.ai admin console. Verify on one machine before rolling out: a plugin that cannot be fetched never loads, and a hook that does not load does not run. ## When Tileward is unreachable - With the plugin, the prompt is blocked. The script runs on the machine, so an unreachable Tileward, a missing key or a crash all block, with the reason shown. Set `TILEWARD_FAIL_OPEN=1` in the environment if you would rather a prompt ran during an outage. - With a direct HTTP hook, the prompt runs: Claude Code logs an unreachable HTTP hook as an error and sends the prompt on. - Claude Code lets the prompt through if a local hook exceeds its timeout, so the script keeps its own timeout under the hook's. ## Related - [Connect a client](https://tileward.com/docs/): every other client's recipe - [Endpoint table](https://tileward.com/docs/#endpoints): which address wants which credential - [Tileward in OpenAI Codex](https://tileward.com/docs/codex/): the same setup for Codex - [Tileward in ChatGPT](https://tileward.com/docs/chatgpt/): Context as a ChatGPT connector - [Console](https://app.tileward.com): API keys, policies and connected apps