@topolo/mcp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,8 +6,8 @@ tools rather than shelling out.
6
6
 
7
7
  ## Why both a CLI and an MCP server?
8
8
 
9
- - The **CLI** is for humans, shell scripts, and agents without MCP support.
10
- - The **MCP server** is for agents that speak the protocol natively — it gives
9
+ - The **CLI** (`@topolo/cli`) is for humans, shell scripts, and agents without MCP support.
10
+ - The **MCP server** (`@topolo/mcp`) is for agents that speak the protocol natively — it gives
11
11
  them typed tool schemas, scope-filtered tool advertisement, and structured
12
12
  error responses. Both wrap the same `@topolo/sdk`.
13
13
 
@@ -17,9 +17,37 @@ tools rather than shelling out.
17
17
  npm install -g @topolo/mcp
18
18
  ```
19
19
 
20
+ You don't have to install globally — the registration snippets below use `npx`
21
+ so the server downloads on demand.
22
+
23
+ ## Get a credential
24
+
25
+ Either:
26
+
27
+ - **Long-lived**: mint an API key at the Topolo Developers console
28
+ (`TOPOLO_API_KEY=topo_live_...`). Preferred for persistent agent installs.
29
+ - **Short-lived**: `topolo auth login` with the CLI, then copy the access token
30
+ from `~/.config/topolo/config.json`. Useful for dev and testing.
31
+
20
32
  ## Register with an MCP client
21
33
 
22
- Example (Claude Desktop, `claude_desktop_config.json`):
34
+ ### Claude Code
35
+
36
+ ```bash
37
+ claude mcp add topolo -- npx -y @topolo/mcp
38
+ ```
39
+
40
+ Then set the credential and (optional) agent label in your shell profile so
41
+ Claude Code inherits them when it spawns the server:
42
+
43
+ ```bash
44
+ export TOPOLO_API_KEY=topo_live_...
45
+ export TOPOLO_AGENT_NAME=claude-code
46
+ ```
47
+
48
+ ### Claude Desktop
49
+
50
+ `claude_desktop_config.json`:
23
51
 
24
52
  ```json
25
53
  {
@@ -36,6 +64,13 @@ Example (Claude Desktop, `claude_desktop_config.json`):
36
64
  }
37
65
  ```
38
66
 
67
+ ### Codex / Cursor / generic MCP host
68
+
69
+ Any MCP host that spawns a stdio subprocess works. Point `command` at
70
+ `npx -y @topolo/mcp` and pass the same env vars. Most Codex-style setups also
71
+ read `AGENTS.md` files — see `@topolo/cli`'s `skills/codex/AGENTS.md` for a
72
+ ready-made agent guide that covers both the CLI and this MCP.
73
+
39
74
  ## Supported env vars
40
75
 
41
76
  | Var | Purpose |
@@ -43,13 +78,21 @@ Example (Claude Desktop, `claude_desktop_config.json`):
43
78
  | `TOPOLO_API_KEY` | Platform API key (preferred) |
44
79
  | `TOPOLO_ACCESS_TOKEN` | Short-lived JWT (dev/testing) |
45
80
  | `TOPOLO_AGENT_NAME` | Human-readable agent label for audit logs |
46
- | `TOPOLO_SERVICE_URL_<ID>` | Override a service base URL (`_AUTH`, `_CRM`, ...) |
81
+ | `TOPOLO_SERVICE_URL_<ID>` | Override a service base URL (e.g. `_AUTH`, `_CRM`) |
47
82
 
48
- On startup the server:
83
+ Exactly one credential var must be set. If both are present, `TOPOLO_API_KEY`
84
+ wins.
49
85
 
50
- 1. Refuses to start if no credential is set.
51
- 2. Introspects the credential against TopoloAuth to load granted scopes.
52
- 3. Filters the advertised tool list to only those the credential can use.
86
+ ## Startup sequence
87
+
88
+ 1. Resolve the credential from env. **Refuse to start** if none is set.
89
+ 2. Call `GET /api/me` to load the user's granted scopes + role.
90
+ 3. Filter `TOOLS` by those scopes — agents never see a tool they cannot use.
91
+ 4. Connect the stdio transport and begin serving MCP requests.
92
+
93
+ Startup is synchronous and fast (< 500 ms typical). If the credential is
94
+ rejected, the process logs the error to stderr and exits non-zero — host
95
+ clients surface that as a failed server launch.
53
96
 
54
97
  ## Tools (Phase 1)
55
98
 
@@ -76,6 +119,22 @@ later phases alongside typed SDK modules, each annotated with
76
119
  the call explicitly passes `confirm: true`. Mutating tools (when introduced)
77
120
  will require the host client to approve before invocation.
78
121
 
122
+ ## Troubleshooting
123
+
124
+ - **"TOPOLO_API_KEY or TOPOLO_ACCESS_TOKEN must be set"** — no credential
125
+ reached the subprocess. In Claude Desktop, double-check the `env` block in
126
+ `claude_desktop_config.json`. In Claude Code, the server inherits your shell
127
+ env, so make sure the var is exported in the profile your launcher reads.
128
+ - **"credential rejected"** — token is expired or revoked. For API keys, mint
129
+ a fresh one. For access tokens, re-run `topolo auth login` and copy the new
130
+ token.
131
+ - **Tool missing from the list** — the credential doesn't grant the required
132
+ scope. Check `topolo whoami` to see the current scopes; either broaden the
133
+ API key's permissions or switch to one that already has them.
134
+ - **Tool call returns `Permission denied`** — the scope check on the backend
135
+ disagrees with startup introspection (rare, but possible across scope
136
+ changes). Re-spawn the server to refresh the cached scope set.
137
+
79
138
  ## Development
80
139
 
81
140
  ```bash
@@ -86,7 +145,17 @@ TOPOLO_API_KEY=topo_live_... node dist/index.js
86
145
  ```
87
146
 
88
147
  The server speaks MCP over stdio; when running standalone it just blocks
89
- waiting for JSON-RPC on stdin.
148
+ waiting for JSON-RPC on stdin. To drive it manually, use the MCP Inspector:
149
+
150
+ ```bash
151
+ npx @modelcontextprotocol/inspector node dist/index.js
152
+ ```
153
+
154
+ ## Release flow
155
+
156
+ Pushing a `v<x.y.z>` tag to `main` triggers GitHub Actions to typecheck, test,
157
+ build, verify the tag matches `package.json`, and publish to npm via the
158
+ `NPM_TOKEN` secret. No developer-machine credentials involved.
90
159
 
91
160
  ## Phase 2 (planned)
92
161
 
@@ -94,3 +163,4 @@ waiting for JSON-RPC on stdin.
94
163
  in TopoloAuth.
95
164
  - Dynamic tool registration as more `@topolo/sdk` modules ship.
96
165
  - HTTP transport in addition to stdio, for hosted (non-subprocess) deployments.
166
+ - Optional `--provenance` on npm publish once the repo is public.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  ListToolsRequestSchema
9
9
  } from "@modelcontextprotocol/sdk/types.js";
10
10
 
11
- // ../packages/topolo-sdk/dist/index.js
11
+ // node_modules/@topolo/sdk/dist/index.js
12
12
  function applyAuthHeaders(headers, credential) {
13
13
  if (credential.kind === "api_key") {
14
14
  headers.set("X-Api-Key", credential.apiKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Model Context Protocol server for the Topolo platform. Exposes scope-gated tools that third-party agents (Claude, Codex, etc.) can call natively.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "@modelcontextprotocol/sdk": "^1.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@topolo/sdk": "file:../packages/topolo-sdk",
24
+ "@topolo/sdk": "latest",
25
25
  "@types/node": "^20.12.0",
26
26
  "tsup": "^8.0.0",
27
27
  "typescript": "^5.4.0",