@dashclaw/mcp-server 1.0.0 → 1.0.2

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
@@ -7,7 +7,7 @@ MCP server for [DashClaw](https://github.com/ucsandman/DashClaw) governance. Exp
7
7
  ### Claude Desktop / Claude Code (stdio)
8
8
 
9
9
  ```bash
10
- npx @dashclaw/mcp-server --url https://your-dashclaw.vercel.app --key oc_live_xxx
10
+ npx -y @dashclaw/mcp-server --url https://your-dashclaw.vercel.app --key oc_live_xxx --agent-id claude-desktop
11
11
  ```
12
12
 
13
13
  Or add to `claude_desktop_config.json`:
@@ -17,16 +17,19 @@ Or add to `claude_desktop_config.json`:
17
17
  "mcpServers": {
18
18
  "dashclaw": {
19
19
  "command": "npx",
20
- "args": ["@dashclaw/mcp-server"],
20
+ "args": ["-y", "@dashclaw/mcp-server"],
21
21
  "env": {
22
22
  "DASHCLAW_URL": "https://your-dashclaw.vercel.app",
23
- "DASHCLAW_API_KEY": "oc_live_xxx"
23
+ "DASHCLAW_API_KEY": "oc_live_xxx",
24
+ "DASHCLAW_AGENT_ID": "claude-desktop"
24
25
  }
25
26
  }
26
27
  }
27
28
  }
28
29
  ```
29
30
 
31
+ **About `DASHCLAW_AGENT_ID`:** this is the name that shows up on `/fleet`, `/decisions`, and every other governance surface. If you omit it, the server auto-derives an `agent_id` from the MCP protocol's `clientInfo.name` (e.g. `claude-ai` for Claude Desktop, `cursor-vscode` for Cursor) so calls don't silently commingle with other agents — but a human-friendly name like `claude-desktop` is what you actually want for dashboard readability. Explicit configuration always wins over auto-derivation.
32
+
30
33
  ### Claude Managed Agents (Streamable HTTP)
31
34
 
32
35
  If you're running DashClaw, the MCP endpoint is built in at `/api/mcp`:
@@ -45,7 +45,31 @@ config.url = config.url || process.env.DASHCLAW_URL;
45
45
  config.apiKey = config.apiKey || process.env.DASHCLAW_API_KEY;
46
46
  config.agentId = config.agentId || process.env.DASHCLAW_AGENT_ID;
47
47
 
48
- const server = createServer(config);
48
+ const { server, client } = createServer(config);
49
49
  const transport = new StdioServerTransport();
50
50
  await server.connect(transport);
51
+
52
+ // Auto-derive agent_id from the MCP `initialize` clientInfo when the user
53
+ // hasn't supplied --agent-id or DASHCLAW_AGENT_ID. Without this, every call
54
+ // from Claude Desktop, MCP Inspector, etc. arrives with an empty agent_id and
55
+ // silently commingles with whatever default the server falls back to (almost
56
+ // always `claude-code`). The MCP protocol's clientInfo.name identifies the
57
+ // connecting client (e.g. "claude-ai" for Claude Desktop, "cursor-vscode" for
58
+ // Cursor) so we use it as a sensible default — explicit configuration still
59
+ // wins, because we only set it when client.agentId is empty.
60
+ const originalOnMessage = transport.onmessage;
61
+ if (typeof originalOnMessage === 'function') {
62
+ transport.onmessage = (message) => {
63
+ if (
64
+ message?.method === 'initialize' &&
65
+ !client.agentId &&
66
+ message.params?.clientInfo?.name
67
+ ) {
68
+ client.agentId = String(message.params.clientInfo.name);
69
+ console.error(`[dashclaw] auto-derived agent_id from MCP clientInfo: ${client.agentId}`);
70
+ }
71
+ return originalOnMessage(message);
72
+ };
73
+ }
74
+
51
75
  console.error('@dashclaw/mcp-server running on stdio');
package/lib/server.js CHANGED
@@ -33,7 +33,10 @@ function jsonSchemaToInputSchema(jsonSchema) {
33
33
  * @param {string} [config.url] - DashClaw instance URL (default: http://localhost:3000)
34
34
  * @param {string} [config.apiKey] - API key (oc_live_ prefix)
35
35
  * @param {string} [config.agentId] - Default agent ID for tool calls
36
- * @returns {McpServer} Configured MCP server ready to connect
36
+ * @returns {{ server: McpServer, client: DashClawClient }} Configured MCP server
37
+ * ready to connect, plus the DashClawClient so callers (the stdio bin) can
38
+ * auto-derive `agentId` from the MCP initialize handshake when no
39
+ * --agent-id / DASHCLAW_AGENT_ID was provided.
37
40
  */
38
41
  export function createServer(config = {}) {
39
42
  // 1. Create DashClawClient
@@ -51,7 +54,7 @@ export function createServer(config = {}) {
51
54
  const server = new McpServer(
52
55
  {
53
56
  name: '@dashclaw/mcp-server',
54
- version: '1.0.0',
57
+ version: '1.0.2',
55
58
  },
56
59
  {
57
60
  capabilities: {
@@ -128,5 +131,5 @@ export function createServer(config = {}) {
128
131
  }
129
132
  }
130
133
 
131
- return server;
134
+ return { server, client };
132
135
  }
package/lib/tools.js CHANGED
@@ -397,7 +397,15 @@ export const TOOL_DEFINITIONS = [
397
397
  * @returns {Object<string, function>}
398
398
  */
399
399
  export function createToolHandlers(client) {
400
- const agentId = (input) => input.agent_id || client.agentId;
400
+ // Priority: server-configured agent_id (DASHCLAW_AGENT_ID / --agent-id /
401
+ // auto-derived from MCP clientInfo) wins over anything the LLM passes in the
402
+ // tool call. This is deliberate: agent identity is a governance primitive,
403
+ // and letting the LLM pick its own agent_id based on prompt context (e.g.
404
+ // it sees "smoke test" and picks "claude-mcp-smoketest") breaks attribution
405
+ // and lets a single misbehaving prompt impersonate a different agent. The
406
+ // input.agent_id field is preserved only as a last-resort fallback for
407
+ // configurations that intentionally run without a server-level default.
408
+ const agentId = (input) => client.agentId || input.agent_id;
401
409
 
402
410
  return {
403
411
  async dashclaw_optimal_files_preview(input) {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dashclaw/mcp-server",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for DashClaw governance — guard, record, invoke, and discover capabilities.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "dashclaw-mcp": "./bin/dashclaw-mcp.js"
7
+ "dashclaw-mcp": "bin/dashclaw-mcp.js"
8
8
  },
9
9
  "main": "./lib/server.js",
10
10
  "exports": {