summaryrefslogtreecommitdiff
path: root/scripts/test-claude-mcp-without-builtin-tools.sh
blob: 9affc3e528a40116625f9e79fd56b6d3733b5f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
cd "$tmp"

cat > mcp.json <<'JSON'
{
  "mcpServers": {
    "panto-test": {
      "command": "node",
      "args": ["server.js"]
    }
  }
}
JSON

cat > server.js <<'JS'
#!/usr/bin/env node
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin });

function send(message) {
  process.stdout.write(JSON.stringify(message) + "\n");
}

rl.on("line", (line) => {
  let message;
  try {
    message = JSON.parse(line);
  } catch {
    return;
  }

  if (message.method === "initialize") {
    send({
      jsonrpc: "2.0",
      id: message.id,
      result: {
        protocolVersion: "2024-11-05",
        capabilities: { tools: {} },
        serverInfo: { name: "panto-test", version: "0.0.1" }
      }
    });
  } else if (message.method === "notifications/initialized") {
    // No response for notifications.
  } else if (message.method === "tools/list") {
    send({
      jsonrpc: "2.0",
      id: message.id,
      result: {
        tools: [
          {
            name: "ping",
            description: "Return pong-from-mcp",
            inputSchema: {
              type: "object",
              properties: {},
              additionalProperties: false
            }
          }
        ]
      }
    });
  } else if (message.method === "tools/call") {
    send({
      jsonrpc: "2.0",
      id: message.id,
      result: {
        content: [{ type: "text", text: "pong-from-mcp" }]
      }
    });
  } else if (message.id !== undefined) {
    send({ jsonrpc: "2.0", id: message.id, result: {} });
  }
});
JS
chmod +x server.js

cat >&2 <<'EOF'
Starting Claude with built-in tools disabled and one MCP tool enabled.

Manual test prompt:
  call the ping MCP tool

Expected useful result:
  pong-from-mcp

If Claude says no tools are available, --tools "" also disables MCP tools.
EOF

unset ANTHROPIC_API_KEY
exec claude \
  --tools "" \
  --strict-mcp-config \
  --mcp-config mcp.json \
  --disable-slash-commands \
  --no-chrome \
  --system-prompt 'If tool mcp__panto-test__ping exists, call it when asked. Otherwise say unavailable.'