Agents and MCP
Create a personal API token, connect Claude Code, Codex or any MCP client, and see what a token can and can't do.
The MCP server lets an agent read and write the workspace: Claude Code, Codex, any other MCP client, or an agent you build yourself with an agent SDK and a model API key. It is an ordinary API client: it stores nothing, holds no token between requests, and every call goes through the same permission checks as the web app. A self-hosted installation serves it at APP_URL/mcp, with nothing to configure.
Create a token
Agents sign in with a personal API token, which acts as the person who made it. In the app, open the user menu and choose API tokens.
- Name the token after the agent that will use it.
- Choose Read only (the default) or Read and write.
- Untick any module the agent doesn't need.
- Pick an expiry: 30, 90, 180 or 365 days. The default is 90, and no token lasts forever.
The token starts with knw_. It is shown once, with ready-to-copy setup commands, and only its hash is stored. The same page lists your tokens, shows when each was last used, and lets you revoke them.
Connect a client
The address is your APP_URL followed by /mcp. For Claude Code:
claude mcp add --transport http knotworking https://knot.example.com/mcp \
--header "Authorization: Bearer knw_…"
Codex reads the token from an environment variable instead of the command line:
export KNOTWORKING_TOKEN="knw_…"
codex mcp add knotworking --url https://knot.example.com/mcp \
--bearer-token-env-var KNOTWORKING_TOKEN
Any client that supports remote MCP servers with custom headers works the same way. Give it the URL, and send the token in an Authorization: Bearer header. Serve the endpoint over HTTPS, so tokens don't cross the network in clear text.
Local (stdio) clients
A client that launches a local process, such as Claude Desktop, can run the server over stdio instead. Build the server from a checkout and point it at your installation. The API isn't reachable from outside, but the web app proxies it under /api.
{
"mcpServers": {
"knotworking": {
"command": "node",
"args": ["/absolute/path/to/knotworking/apps/mcp/dist/stdio.js"],
"env": {
"KNOTWORKING_API_URL": "https://knot.example.com/api",
"KNOTWORKING_API_TOKEN": "knw_…",
"KNOTWORKING_DEFAULT_WORKSPACE": "knotworking"
}
}
}
}
Codex takes the same command and environment in ~/.codex/config.toml:
[mcp_servers.knotworking]
command = "node"
args = ["/absolute/path/to/knotworking/apps/mcp/dist/stdio.js"]
[mcp_servers.knotworking.env]
KNOTWORKING_API_URL = "https://knot.example.com/api"
KNOTWORKING_API_TOKEN = "knw_…"
KNOTWORKING_DEFAULT_WORKSPACE = "knotworking"
Run pnpm --filter @knotworking/mcp build first, so dist/stdio.js exists.
Choose which tools an agent sees
The tool list is sent to the agent at the start of every conversation and stays in its context. Listing every tool natively is large: with every module on, it is 286 tools and about 97,000 tokens. So by default the server lists a small core of about 15 tools (about 4,000 tokens) and lets the agent pull in the rest as it needs them.
- Reading goes through
find_recordsandget_record, which cover about 80 kinds of record. A few everyday tools, such assearch_tasks,create_taskandsearch_documents, stay listed. - For anything else, the agent calls
describe_moduleonce to see a module's tools, thenrun_module_toolto use one. Each call is checked exactly as if the tool had been called directly.
You can narrow what a connection is offered by adding options to the URL (or, over stdio, setting an environment variable):
| To | Over HTTP | Over stdio |
|---|---|---|
| Offer read-only tools | ?tools=read | KNOTWORKING_MCP_TOOLS=read |
| Offer only some modules | ?modules=bi,purchasing,items | KNOTWORKING_MCP_MODULES=bi,purchasing,items |
| List every tool natively | ?list=all | KNOTWORKING_MCP_LIST=all |
claude mcp add --transport http knotworking "https://knot.example.com/mcp?modules=bi,purchasing,items" \
--header "Authorization: Bearer knw_…"
- These options only narrow. A module the token's person can't read is never offered, and the API checks every call. In read-only mode the write tools aren't registered at all, so they can't be called through
run_module_tooleither. - Platform tools such as
get_workspace_overviewalways stay. The server refuses an unknown module name, or a value fortoolsorlistthat it doesn't know. - Use
?list=allfor clients that handle long tool lists well, or for scripts that call tools by name. A client that called module tools by name, such aslist_items, needs it, or needs to switch tofind_recordsandrun_module_tool. - Untick modules when you create a token to limit what it may read, not only what is listed.
What a token can do
- A read token can only make GET requests. Write tools answer
token_read_only. - A write token acts as its owner, so their role still applies: a guest's write token is read-only.
- The agent only sees tools for modules that are active, that its person can read, and that the token allows.
- Tokens never reach admin routes or anyone's personal calendar. Agents can read workspace meetings but not change them.
- Delete tools cover tasks, projects, documents and time entries only, each behind
confirm: true. - Writes land in the sync log like anyone's, attributed to the token's owner.
Actions that need a person
Some actions refuse tokens and need a signed-in person. They come in two kinds.
| Kind | Examples | Can be opened to agents |
|---|---|---|
| Operational actions | Sending, closing or cancelling a purchase order; recording waste; adjusting stock; posting a stocktake; cancelling a production batch | Yes, per workspace, by an owner or admin |
| Sign-offs and approvals | Approving suppliers, recipes, SOPs and HACCP plans; QA lot release; training sign-off | Never |
| Records that attest a person did something | SOP acknowledgement, cleaning and calibration records, completed checks | Never |
| Ledger corrections and safety | Reversing stock movements, roll calls, kiosk devices and PINs | Never |
Operational actions are off by default. An owner or admin opens them under Settings, API access, signed in with their own account. Each token must also name the action in its own list, and a new token starts with an empty one. Every attempt through an opened action goes in an audit log, refusals included, and the token's owner and the workspace's admins are notified when one succeeds. A token can also carry a maximum purchase order value.
Security
- Workspace text is written by other people and can contain instructions aimed at an agent. The server tells agents to treat it as data, which lowers the risk but doesn't remove it. Use read tokens for agents that read other people's writing, and check what write-capable agents do.
- Give each agent its own token, so you can revoke one without the others.
- Revoking a token, deleting its user or changing their password stops it at once.
- Serve the MCP endpoint over HTTPS so tokens don't cross the network in clear text.
- Reaching the server by an address that isn't
APP_URLgets403 Invalid Host; add it toMCP_ALLOWED_HOSTS.
Rate limits
Rate limits, batch size and allowed hosts are covered in Configuration. Over a limit, calls get 429 with Retry-After.