Skip to content

Commit ace2d6f

Browse files
hyperpolymathclaude
andcommitted
feat(cartridges): add claude-ai-mcp cartridge — Anthropic Messages API
Adds a BoJ cartridge for the Anthropic Messages API with three tools: claude_chat (Messages endpoint, defaults to claude-sonnet-4-6), claude_count_tokens, and claude_list_models. Auth via ANTHROPIC_API_KEY from vault-mcp. MCP protocol compliant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0dcb296 commit ace2d6f

4 files changed

Lines changed: 570 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"$schema": "https://boj.dev/schemas/cartridge/v1.json",
3+
"spdx": "PMPL-1.0-or-later",
4+
"copyright": "Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath)",
5+
"name": "claude-ai-mcp",
6+
"version": "0.1.0",
7+
"description": "Anthropic Messages API cartridge -- send messages to Claude models, count tokens, manage multi-turn conversations",
8+
"domain": "AI",
9+
"tier": "Ayo",
10+
"protocols": ["MCP", "REST"],
11+
"auth": {
12+
"method": "api_key_header",
13+
"header": "x-api-key",
14+
"env_var": "ANTHROPIC_API_KEY",
15+
"credential_source": "vault-mcp"
16+
},
17+
"api": {
18+
"base_url": "https://api.anthropic.com/v1",
19+
"content_type": "application/json",
20+
"extra_headers": {
21+
"anthropic-version": "2023-06-01"
22+
}
23+
},
24+
"tools": [
25+
{
26+
"name": "claude_chat",
27+
"description": "Send a message (or multi-turn conversation) to a Claude model and return the text response. Uses the Anthropic Messages API.",
28+
"inputSchema": {
29+
"type": "object",
30+
"properties": {
31+
"messages": {
32+
"type": "array",
33+
"description": "Conversation history. Each entry has 'role' (user|assistant) and 'content' (string).",
34+
"items": {
35+
"type": "object",
36+
"properties": {
37+
"role": { "type": "string", "enum": ["user", "assistant"] },
38+
"content": { "type": "string" }
39+
},
40+
"required": ["role", "content"]
41+
},
42+
"minItems": 1
43+
},
44+
"model": {
45+
"type": "string",
46+
"description": "Model ID. Defaults to claude-sonnet-4-6. Options: claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001.",
47+
"default": "claude-sonnet-4-6"
48+
},
49+
"system": {
50+
"type": "string",
51+
"description": "Optional system prompt placed before the conversation."
52+
},
53+
"max_tokens": {
54+
"type": "number",
55+
"description": "Maximum tokens in the response (default 4096, max 8192).",
56+
"default": 4096
57+
},
58+
"temperature": {
59+
"type": "number",
60+
"description": "Sampling temperature 0.0–1.0 (default 1.0 = standard).",
61+
"default": 1.0
62+
}
63+
},
64+
"required": ["messages"]
65+
}
66+
},
67+
{
68+
"name": "claude_count_tokens",
69+
"description": "Count how many tokens a given set of messages would consume without actually sending them. Uses the Anthropic token-counting endpoint.",
70+
"inputSchema": {
71+
"type": "object",
72+
"properties": {
73+
"messages": {
74+
"type": "array",
75+
"description": "Messages to count tokens for.",
76+
"items": {
77+
"type": "object",
78+
"properties": {
79+
"role": { "type": "string", "enum": ["user", "assistant"] },
80+
"content": { "type": "string" }
81+
},
82+
"required": ["role", "content"]
83+
},
84+
"minItems": 1
85+
},
86+
"model": {
87+
"type": "string",
88+
"description": "Model to count against (affects tokenisation). Defaults to claude-sonnet-4-6.",
89+
"default": "claude-sonnet-4-6"
90+
},
91+
"system": {
92+
"type": "string",
93+
"description": "System prompt to include in the count."
94+
}
95+
},
96+
"required": ["messages"]
97+
}
98+
},
99+
{
100+
"name": "claude_list_models",
101+
"description": "Return the known Claude model IDs available through this cartridge, with tier labels.",
102+
"inputSchema": {
103+
"type": "object",
104+
"properties": {}
105+
}
106+
}
107+
]
108+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
name = "claude-ai-mcp"
3+
description = "Anthropic Messages API cartridge — send messages to Claude models, count tokens, manage conversations"
4+
version = "0.1.0"
5+
domain = "AI"
6+
protocols = [
7+
"MCP",
8+
"REST",
9+
]
10+
tier = "Ayo"
11+
backend = "universal"
12+
generate_panel = true
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"$schema": "https://panll.dev/schemas/panel-manifest/v1.json",
3+
"spdx": "PMPL-1.0-or-later",
4+
"cartridge": "claude-ai-mcp",
5+
"domain": "AI",
6+
"version": "0.1.0",
7+
"panels": [
8+
{
9+
"id": "claude-auth-status",
10+
"title": "Auth Status",
11+
"description": "Whether ANTHROPIC_API_KEY is present and the API is reachable",
12+
"type": "status-indicator",
13+
"data_source": {
14+
"endpoint": "/cartridge/claude-ai-mcp/invoke",
15+
"method": "POST",
16+
"body": { "tool": "status" },
17+
"refresh_interval_ms": 30000
18+
},
19+
"widgets": [
20+
{
21+
"type": "state-badge",
22+
"field": "state",
23+
"states": {
24+
"ready": { "color": "#2ecc71", "icon": "check-circle" },
25+
"no_key": { "color": "#e74c3c", "icon": "key" },
26+
"api_error": { "color": "#e74c3c", "icon": "alert-triangle" },
27+
"rate_limited": { "color": "#f39c12", "icon": "clock" }
28+
}
29+
}
30+
]
31+
},
32+
{
33+
"id": "claude-active-model",
34+
"title": "Active Model",
35+
"description": "Default model in use and its tier",
36+
"type": "metric",
37+
"data_source": {
38+
"endpoint": "/cartridge/claude-ai-mcp/invoke",
39+
"method": "POST",
40+
"body": { "tool": "claude_list_models" },
41+
"refresh_interval_ms": 60000
42+
},
43+
"widgets": [
44+
{ "type": "text", "field": "default", "label": "Default Model", "icon": "cpu" },
45+
{ "type": "counter", "field": "models.length", "label": "Available Models", "icon": "layers" }
46+
]
47+
},
48+
{
49+
"id": "claude-usage",
50+
"title": "Token Usage",
51+
"description": "Cumulative input and output tokens sent through this cartridge in the current session",
52+
"type": "metric",
53+
"data_source": {
54+
"endpoint": "/cartridge/claude-ai-mcp/usage",
55+
"method": "GET",
56+
"refresh_interval_ms": 10000
57+
},
58+
"widgets": [
59+
{ "type": "counter", "field": "input_tokens", "label": "Input Tokens", "icon": "arrow-up" },
60+
{ "type": "counter", "field": "output_tokens", "label": "Output Tokens", "icon": "arrow-down" },
61+
{ "type": "counter", "field": "total_requests","label": "Requests", "icon": "activity" }
62+
]
63+
},
64+
{
65+
"id": "claude-request-log",
66+
"title": "Request Log",
67+
"description": "Recent messages sent through the cartridge — model, token cost, stop reason",
68+
"type": "log-stream",
69+
"data_source": {
70+
"endpoint": "/cartridge/claude-ai-mcp/audit",
71+
"method": "GET",
72+
"refresh_interval_ms": 15000,
73+
"max_entries": 50
74+
},
75+
"widgets": [
76+
{
77+
"type": "log-table",
78+
"columns": [
79+
{ "field": "timestamp", "label": "Time", "format": "datetime" },
80+
{ "field": "model", "label": "Model" },
81+
{ "field": "input_tokens", "label": "In Tokens" },
82+
{ "field": "output_tokens","label": "Out Tokens" },
83+
{ "field": "stop_reason", "label": "Stop" }
84+
]
85+
}
86+
]
87+
}
88+
]
89+
}

0 commit comments

Comments
 (0)