@argosvix/mcp-server 0.2.0-alpha.1 → 0.3.1-alpha.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 +59 -3
- package/dist/http.d.ts +36 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +411 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +19 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -45
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +27 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +169 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +34 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +123 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +82 -6
- package/dist/tools.js.map +1 -1
- package/dist/tools.test.js +74 -15
- package/dist/tools.test.js.map +1 -1
- package/package.json +50 -50
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @argosvix/mcp-server
|
|
2
2
|
|
|
3
|
-
**Phase
|
|
3
|
+
**Phase 3 alpha** — Argosvix MCP server lets AI agents (Claude Desktop, Cursor, Codex CLI, custom MCP clients) query their LLM observability data directly from the conversation. Supports both **stdio** (subprocess) and **HTTP** (remote / self-host) transports.
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.com/package/@argosvix/mcp-server)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -60,17 +60,21 @@ Edit `~/.cursor/mcp.json`:
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
## Tools (Phase
|
|
63
|
+
## Tools (Phase 1-3)
|
|
64
64
|
|
|
65
65
|
| Tool | Purpose | Type |
|
|
66
66
|
|---|---|---|
|
|
67
67
|
| `query_calls` | Recent LLM call records, filterable by provider / model / time range | read |
|
|
68
68
|
| `get_cost_summary` | Aggregate cost / calls / tokens by provider or model | read |
|
|
69
69
|
| `list_alerts` | Configured alerts + recent trigger status | read |
|
|
70
|
+
| `get_alert` | Detail of a specific alert + recent trigger history | read |
|
|
71
|
+
| `list_alert_events` | Alert trigger events across the account (notification history) | read |
|
|
70
72
|
| `silence_alert` | Mute a specific alert (= temporary notification stop, default 24h) | write |
|
|
71
73
|
| `unsilence_alert` | Resume notifications for a previously muted alert | write |
|
|
74
|
+
| `create_alert` | Create a new alert rule (cost / error rate / latency / anomaly) | write |
|
|
72
75
|
|
|
73
|
-
Phase 3 backlog: `
|
|
76
|
+
Phase 3 backlog (= not yet shipped): `acknowledge_alert`, MCP `resources` /
|
|
77
|
+
`prompts` (traces and dashboards as first-class MCP entities).
|
|
74
78
|
|
|
75
79
|
## Privacy
|
|
76
80
|
|
|
@@ -87,3 +91,55 @@ npm test
|
|
|
87
91
|
## License
|
|
88
92
|
|
|
89
93
|
MIT © Yuto Makihara (Argosvix). See [LICENSE](LICENSE).
|
|
94
|
+
|
|
95
|
+
## HTTP transport (new in 0.3.0-alpha.1)
|
|
96
|
+
|
|
97
|
+
The server can also run as a remote MCP endpoint over HTTP, suitable for
|
|
98
|
+
self-hosting or multi-tenant scenarios where API key is supplied per request.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Start HTTP transport (default: 127.0.0.1:3000)
|
|
102
|
+
argosvix-mcp --http
|
|
103
|
+
|
|
104
|
+
# Bind to all interfaces with custom port + allowed Host headers
|
|
105
|
+
MCP_HTTP_HOST=0.0.0.0 \
|
|
106
|
+
MCP_HTTP_PORT=4000 \
|
|
107
|
+
MCP_HTTP_ALLOWED_HOSTS="mcp.example.com,localhost:4000" \
|
|
108
|
+
argosvix-mcp --http
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Endpoints
|
|
112
|
+
|
|
113
|
+
- `GET /health` → `200 OK` with server name/version (no auth)
|
|
114
|
+
- `POST /mcp` → MCP JSON-RPC endpoint (auth required)
|
|
115
|
+
|
|
116
|
+
### Client example
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
curl -X POST http://localhost:3000/mcp \
|
|
120
|
+
-H "Authorization: Bearer argk_..." \
|
|
121
|
+
-H "Content-Type: application/json" \
|
|
122
|
+
-H "Accept: application/json, text/event-stream" \
|
|
123
|
+
-d '{
|
|
124
|
+
"jsonrpc": "2.0",
|
|
125
|
+
"id": 1,
|
|
126
|
+
"method": "tools/list",
|
|
127
|
+
"params": {}
|
|
128
|
+
}'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Auth model
|
|
132
|
+
|
|
133
|
+
Each request must include `Authorization: Bearer <api-key>` with a valid
|
|
134
|
+
Argosvix API key (issue at https://dashboard.argosvix.com/api-keys). The
|
|
135
|
+
server uses stateless mode (no session ID), so each request is independent
|
|
136
|
+
and may carry a different key.
|
|
137
|
+
|
|
138
|
+
### Security notes
|
|
139
|
+
|
|
140
|
+
- Default bind is `127.0.0.1` (localhost only). Use `MCP_HTTP_HOST=0.0.0.0`
|
|
141
|
+
to expose externally, but pair with a reverse proxy + TLS in production.
|
|
142
|
+
- DNS rebinding protection is applied for localhost binds by checking the
|
|
143
|
+
`Host` header against a known-localhost allow list. Use
|
|
144
|
+
`MCP_HTTP_ALLOWED_HOSTS` (comma-separated) when binding non-locally.
|
|
145
|
+
- Body size is capped at 1 MiB.
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport entry for Argosvix MCP server (Phase 3 = remote MCP server)。
|
|
3
|
+
*
|
|
4
|
+
* @modelcontextprotocol/sdk の `StreamableHTTPServerTransport` (= Streamable HTTP、
|
|
5
|
+
* MCP の modern spec) を 使い、 stateless mode で 1 request = 1 MCP session として
|
|
6
|
+
* carry。 stdio mode と異なり、 認証情報 (= ARGOSVIX_API_KEY) は env var ではなく
|
|
7
|
+
* 各 request の `Authorization: Bearer <key>` header から取り出す。
|
|
8
|
+
*
|
|
9
|
+
* 起動:
|
|
10
|
+
* argosvix-mcp --http
|
|
11
|
+
* # オプション:
|
|
12
|
+
* MCP_HTTP_PORT=4000 MCP_HTTP_HOST=0.0.0.0 \
|
|
13
|
+
* MCP_HTTP_ALLOWED_HOSTS=mcp.example.com \
|
|
14
|
+
* MCP_HTTP_ALLOWED_ORIGINS=https://app.example.com \
|
|
15
|
+
* argosvix-mcp --http
|
|
16
|
+
*
|
|
17
|
+
* client 例 (= MCP message を JSON-RPC で 直接送る):
|
|
18
|
+
* curl -X POST http://localhost:3000/mcp \
|
|
19
|
+
* -H "Authorization: Bearer argk_..." \
|
|
20
|
+
* -H "Content-Type: application/json" \
|
|
21
|
+
* -H "Accept: application/json, text/event-stream" \
|
|
22
|
+
* -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
|
|
23
|
+
*
|
|
24
|
+
* セキュリティ設計 (= Codex review fix carry):
|
|
25
|
+
* - localhost bind (= 127.0.0.1 / localhost / ::1) では Host header を localhost
|
|
26
|
+
* allow list で 厳密検証 (= DNS rebinding 防御)。
|
|
27
|
+
* - non-local bind (= 0.0.0.0 等) では MCP_HTTP_ALLOWED_HOSTS の明示設定を必須化
|
|
28
|
+
* (= fail-closed)、 未設定なら起動 warning + 全 request を 403 reject。
|
|
29
|
+
* - CORS は MCP_HTTP_ALLOWED_ORIGINS で allow list 化 (= '*' は使わない)、
|
|
30
|
+
* 未設定時は localhost-bind なら localhost-origin のみ allow、 それ以外は CORS
|
|
31
|
+
* header を返さず browser 経由 access を block。
|
|
32
|
+
* - shutdown は connection tracking + grace period timeout で keep-alive / SSE が
|
|
33
|
+
* 残っても確実に終了する設計、 SIGTERM/SIGINT 多重発火は flag で 1 回限定。
|
|
34
|
+
*/
|
|
35
|
+
export declare function runHttp(): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AA6RH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAuI7C"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport entry for Argosvix MCP server (Phase 3 = remote MCP server)。
|
|
3
|
+
*
|
|
4
|
+
* @modelcontextprotocol/sdk の `StreamableHTTPServerTransport` (= Streamable HTTP、
|
|
5
|
+
* MCP の modern spec) を 使い、 stateless mode で 1 request = 1 MCP session として
|
|
6
|
+
* carry。 stdio mode と異なり、 認証情報 (= ARGOSVIX_API_KEY) は env var ではなく
|
|
7
|
+
* 各 request の `Authorization: Bearer <key>` header から取り出す。
|
|
8
|
+
*
|
|
9
|
+
* 起動:
|
|
10
|
+
* argosvix-mcp --http
|
|
11
|
+
* # オプション:
|
|
12
|
+
* MCP_HTTP_PORT=4000 MCP_HTTP_HOST=0.0.0.0 \
|
|
13
|
+
* MCP_HTTP_ALLOWED_HOSTS=mcp.example.com \
|
|
14
|
+
* MCP_HTTP_ALLOWED_ORIGINS=https://app.example.com \
|
|
15
|
+
* argosvix-mcp --http
|
|
16
|
+
*
|
|
17
|
+
* client 例 (= MCP message を JSON-RPC で 直接送る):
|
|
18
|
+
* curl -X POST http://localhost:3000/mcp \
|
|
19
|
+
* -H "Authorization: Bearer argk_..." \
|
|
20
|
+
* -H "Content-Type: application/json" \
|
|
21
|
+
* -H "Accept: application/json, text/event-stream" \
|
|
22
|
+
* -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
|
|
23
|
+
*
|
|
24
|
+
* セキュリティ設計 (= Codex review fix carry):
|
|
25
|
+
* - localhost bind (= 127.0.0.1 / localhost / ::1) では Host header を localhost
|
|
26
|
+
* allow list で 厳密検証 (= DNS rebinding 防御)。
|
|
27
|
+
* - non-local bind (= 0.0.0.0 等) では MCP_HTTP_ALLOWED_HOSTS の明示設定を必須化
|
|
28
|
+
* (= fail-closed)、 未設定なら起動 warning + 全 request を 403 reject。
|
|
29
|
+
* - CORS は MCP_HTTP_ALLOWED_ORIGINS で allow list 化 (= '*' は使わない)、
|
|
30
|
+
* 未設定時は localhost-bind なら localhost-origin のみ allow、 それ以外は CORS
|
|
31
|
+
* header を返さず browser 経由 access を block。
|
|
32
|
+
* - shutdown は connection tracking + grace period timeout で keep-alive / SSE が
|
|
33
|
+
* 残っても確実に終了する設計、 SIGTERM/SIGINT 多重発火は flag で 1 回限定。
|
|
34
|
+
*/
|
|
35
|
+
import { createServer, } from "node:http";
|
|
36
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
37
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
38
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
39
|
+
import { tools, dispatchTool } from "./tools.js";
|
|
40
|
+
const SERVER_NAME = "argosvix";
|
|
41
|
+
const SERVER_VERSION = "0.3.1-alpha.1";
|
|
42
|
+
const API_BASE = process.env["ARGOSVIX_API_BASE"] ?? "https://ingest.argosvix.com";
|
|
43
|
+
const PORT = Number.parseInt(process.env["MCP_HTTP_PORT"] ?? "3000", 10);
|
|
44
|
+
const HOST = process.env["MCP_HTTP_HOST"] ?? "127.0.0.1";
|
|
45
|
+
// 過大 body による メモリ枯渇防止。 通常の MCP message は 数 KB 未満。
|
|
46
|
+
const MAX_BODY_BYTES = 1_048_576; // 1 MiB
|
|
47
|
+
// graceful shutdown 用 grace period (= keep-alive / SSE の自然 close を待つ時間)
|
|
48
|
+
const SHUTDOWN_GRACE_MS = 10_000;
|
|
49
|
+
// localhost bind 判定 (= DNS rebinding / CORS の default 緩和を 限定する閾値)
|
|
50
|
+
const isLocalBind = HOST === "127.0.0.1" || HOST === "localhost" || HOST === "::1";
|
|
51
|
+
// Host header allow list (= 比較時に大文字小文字 ignore するため格納時 toLowerCase)
|
|
52
|
+
const DEFAULT_LOCAL_HOSTS = new Set([
|
|
53
|
+
"localhost",
|
|
54
|
+
"127.0.0.1",
|
|
55
|
+
`localhost:${PORT}`,
|
|
56
|
+
`127.0.0.1:${PORT}`,
|
|
57
|
+
"[::1]",
|
|
58
|
+
`[::1]:${PORT}`,
|
|
59
|
+
]);
|
|
60
|
+
const allowedHostsEnv = process.env["MCP_HTTP_ALLOWED_HOSTS"];
|
|
61
|
+
const allowedHosts = allowedHostsEnv
|
|
62
|
+
? new Set(allowedHostsEnv
|
|
63
|
+
.split(",")
|
|
64
|
+
.map((s) => s.trim().toLowerCase())
|
|
65
|
+
.filter((s) => s.length > 0))
|
|
66
|
+
: DEFAULT_LOCAL_HOSTS;
|
|
67
|
+
// CORS Origin allow list (= '*' は使わない、 明示 allowlist 方式)
|
|
68
|
+
const allowedOriginsEnv = process.env["MCP_HTTP_ALLOWED_ORIGINS"];
|
|
69
|
+
const allowedOrigins = allowedOriginsEnv
|
|
70
|
+
? new Set(allowedOriginsEnv
|
|
71
|
+
.split(",")
|
|
72
|
+
.map((s) => s.trim())
|
|
73
|
+
.filter((s) => s.length > 0))
|
|
74
|
+
: null;
|
|
75
|
+
// localhost-bind かつ MCP_HTTP_ALLOWED_ORIGINS 未設定 のとき、 localhost origin
|
|
76
|
+
// だけを許可する default CORS 判定。
|
|
77
|
+
const LOCALHOST_ORIGIN_PATTERN = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/;
|
|
78
|
+
function extractBearer(req) {
|
|
79
|
+
const auth = req.headers["authorization"];
|
|
80
|
+
if (typeof auth !== "string")
|
|
81
|
+
return null;
|
|
82
|
+
const m = /^Bearer\s+(\S+)$/.exec(auth);
|
|
83
|
+
return m?.[1] ?? null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Host header check (Codex MEDIUM 3 fix = fail-closed)。
|
|
87
|
+
* - localhost bind: 既定 allow list (= DNS rebinding 防御)、 user 設定で上書き可
|
|
88
|
+
* - non-local bind: MCP_HTTP_ALLOWED_HOSTS の明示設定必須 (= 未設定なら全 reject)
|
|
89
|
+
*/
|
|
90
|
+
function checkHost(req) {
|
|
91
|
+
const host = req.headers["host"];
|
|
92
|
+
if (typeof host !== "string")
|
|
93
|
+
return false;
|
|
94
|
+
if (!isLocalBind && !allowedHostsEnv) {
|
|
95
|
+
// non-local bind + allowed hosts 未設定 = 起動時 warning 済、 全 reject で fail-closed
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return allowedHosts.has(host.toLowerCase());
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* CORS header 計算 (Codex MEDIUM 2 fix = '*' 廃止)。
|
|
102
|
+
* - Vary: Origin は常に付与 (= proxy / cache の origin-aware 化)
|
|
103
|
+
* - Access-Control-Allow-Origin は allowlist hit 時のみ反映、 認証 cookie ないので
|
|
104
|
+
* Allow-Credentials は不要 (= Bearer header で per-request 認証)
|
|
105
|
+
* - origin 不一致 / 未指定の non-browser request はそのまま通過 (= CORS の制約外)
|
|
106
|
+
*/
|
|
107
|
+
function corsHeadersFor(req) {
|
|
108
|
+
const headers = {
|
|
109
|
+
Vary: "Origin",
|
|
110
|
+
"Access-Control-Allow-Methods": "POST, GET, DELETE, OPTIONS",
|
|
111
|
+
"Access-Control-Allow-Headers": "Authorization, Content-Type, mcp-session-id, mcp-protocol-version, last-event-id",
|
|
112
|
+
"Access-Control-Expose-Headers": "mcp-session-id, mcp-protocol-version",
|
|
113
|
+
"Access-Control-Max-Age": "86400",
|
|
114
|
+
};
|
|
115
|
+
const origin = req.headers["origin"];
|
|
116
|
+
if (typeof origin !== "string" || origin.length === 0)
|
|
117
|
+
return headers;
|
|
118
|
+
let allowed = false;
|
|
119
|
+
if (allowedOrigins !== null) {
|
|
120
|
+
allowed = allowedOrigins.has(origin);
|
|
121
|
+
}
|
|
122
|
+
else if (isLocalBind) {
|
|
123
|
+
// localhost bind + 設定なし = localhost 系 origin のみ default 許可
|
|
124
|
+
allowed = LOCALHOST_ORIGIN_PATTERN.test(origin);
|
|
125
|
+
}
|
|
126
|
+
if (allowed)
|
|
127
|
+
headers["Access-Control-Allow-Origin"] = origin;
|
|
128
|
+
return headers;
|
|
129
|
+
}
|
|
130
|
+
function applyCorsHeaders(req, res) {
|
|
131
|
+
const headers = corsHeadersFor(req);
|
|
132
|
+
for (const [k, v] of Object.entries(headers))
|
|
133
|
+
res.setHeader(k, v);
|
|
134
|
+
}
|
|
135
|
+
// Codex round 2 MEDIUM 3 fix: CORS preflight 厳格化用の allow set + 判定 helper。
|
|
136
|
+
// corsHeadersFor() と同じ allow ポリシーを 1 箇所で source of truth 化する。
|
|
137
|
+
const ALLOWED_METHODS_SET = new Set([
|
|
138
|
+
"POST",
|
|
139
|
+
"GET",
|
|
140
|
+
"DELETE",
|
|
141
|
+
"OPTIONS",
|
|
142
|
+
]);
|
|
143
|
+
const ALLOWED_HEADERS_SET = new Set([
|
|
144
|
+
"authorization",
|
|
145
|
+
"content-type",
|
|
146
|
+
"mcp-session-id",
|
|
147
|
+
"mcp-protocol-version",
|
|
148
|
+
"last-event-id",
|
|
149
|
+
]);
|
|
150
|
+
function isOriginAllowed(origin) {
|
|
151
|
+
if (origin.length === 0)
|
|
152
|
+
return false;
|
|
153
|
+
if (allowedOrigins !== null)
|
|
154
|
+
return allowedOrigins.has(origin);
|
|
155
|
+
if (isLocalBind)
|
|
156
|
+
return LOCALHOST_ORIGIN_PATTERN.test(origin);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
function isPreflightAllowed(req) {
|
|
160
|
+
const origin = req.headers["origin"];
|
|
161
|
+
if (typeof origin !== "string" || !isOriginAllowed(origin))
|
|
162
|
+
return false;
|
|
163
|
+
// Codex round 3 LOW fix: preflight は仕様上 Access-Control-Request-Method 必須なので、
|
|
164
|
+
// 未指定 / 空文字も 厳格 reject に carry する (= undershoot を 残さない)。
|
|
165
|
+
const reqMethod = req.headers["access-control-request-method"];
|
|
166
|
+
if (typeof reqMethod !== "string" || reqMethod.trim().length === 0) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (!ALLOWED_METHODS_SET.has(reqMethod.trim().toUpperCase()))
|
|
170
|
+
return false;
|
|
171
|
+
const reqHeaders = req.headers["access-control-request-headers"];
|
|
172
|
+
if (typeof reqHeaders === "string" && reqHeaders.length > 0) {
|
|
173
|
+
const requested = reqHeaders
|
|
174
|
+
.split(",")
|
|
175
|
+
.map((s) => s.trim().toLowerCase())
|
|
176
|
+
.filter((s) => s.length > 0);
|
|
177
|
+
for (const h of requested) {
|
|
178
|
+
if (!ALLOWED_HEADERS_SET.has(h))
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
async function readBody(req, maxBytes) {
|
|
185
|
+
let total = 0;
|
|
186
|
+
const chunks = [];
|
|
187
|
+
for await (const chunk of req) {
|
|
188
|
+
const buf = chunk instanceof Buffer ? chunk : Buffer.from(chunk);
|
|
189
|
+
total += buf.length;
|
|
190
|
+
if (total > maxBytes) {
|
|
191
|
+
throw new Error(`request body too large (max ${maxBytes} bytes)`);
|
|
192
|
+
}
|
|
193
|
+
chunks.push(buf);
|
|
194
|
+
}
|
|
195
|
+
const text = Buffer.concat(chunks).toString("utf8");
|
|
196
|
+
if (!text)
|
|
197
|
+
return undefined;
|
|
198
|
+
try {
|
|
199
|
+
return JSON.parse(text);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
throw new Error("invalid JSON body");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function sendJson(res, status, body) {
|
|
206
|
+
if (res.headersSent)
|
|
207
|
+
return;
|
|
208
|
+
res.writeHead(status, {
|
|
209
|
+
"Content-Type": "application/json",
|
|
210
|
+
"Cache-Control": "no-store",
|
|
211
|
+
});
|
|
212
|
+
res.end(JSON.stringify(body));
|
|
213
|
+
}
|
|
214
|
+
function createPerRequestServer(apiKey) {
|
|
215
|
+
const server = new Server({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {} } });
|
|
216
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
|
|
217
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
218
|
+
return dispatchTool({
|
|
219
|
+
name: request.params.name,
|
|
220
|
+
args: request.params.arguments ?? {},
|
|
221
|
+
apiKey,
|
|
222
|
+
apiBase: API_BASE,
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return server;
|
|
226
|
+
}
|
|
227
|
+
async function handleMcpRequest(req, res) {
|
|
228
|
+
// 1) Host check (Codex MEDIUM 3 fix = fail-closed for non-local bind)
|
|
229
|
+
if (!checkHost(req)) {
|
|
230
|
+
sendJson(res, 403, { error: "host header not allowed" });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
// 2) Bearer 認証
|
|
234
|
+
const apiKey = extractBearer(req);
|
|
235
|
+
if (!apiKey) {
|
|
236
|
+
// RFC 6750 = WWW-Authenticate header で how-to を伝える
|
|
237
|
+
if (!res.headersSent) {
|
|
238
|
+
res.setHeader("WWW-Authenticate", 'Bearer realm="argosvix-mcp", error="invalid_request"');
|
|
239
|
+
}
|
|
240
|
+
sendJson(res, 401, {
|
|
241
|
+
error: "missing or malformed Authorization: Bearer <api-key>",
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
// 3) POST の場合 body を parse して transport に渡す (SDK の推奨 pattern)
|
|
246
|
+
let parsedBody = undefined;
|
|
247
|
+
if (req.method === "POST") {
|
|
248
|
+
try {
|
|
249
|
+
parsedBody = await readBody(req, MAX_BODY_BYTES);
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
const message = err instanceof Error ? err.message : "request body parse error";
|
|
253
|
+
const status = /too large/i.test(message) ? 413 : 400;
|
|
254
|
+
sendJson(res, status, { error: message });
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// 4) per-request server + transport (stateless = sessionIdGenerator undefined)
|
|
259
|
+
const server = createPerRequestServer(apiKey);
|
|
260
|
+
const transport = new StreamableHTTPServerTransport({
|
|
261
|
+
sessionIdGenerator: undefined,
|
|
262
|
+
enableJsonResponse: true,
|
|
263
|
+
});
|
|
264
|
+
try {
|
|
265
|
+
await server.connect(transport);
|
|
266
|
+
await transport.handleRequest(req, res, parsedBody);
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
// eslint-disable-next-line no-console
|
|
270
|
+
console.error("[argosvix-mcp/http] request error:", err);
|
|
271
|
+
sendJson(res, 500, { error: "internal server error" });
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
try {
|
|
275
|
+
await transport.close();
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// ignore
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export async function runHttp() {
|
|
283
|
+
if (!isLocalBind && !allowedHostsEnv) {
|
|
284
|
+
// Codex MEDIUM 3 fix: 起動時に明示警告 (= 全 request が 403 になる旨)
|
|
285
|
+
// eslint-disable-next-line no-console
|
|
286
|
+
console.error(`[argosvix-mcp] WARNING: HOST=${HOST} is non-local but MCP_HTTP_ALLOWED_HOSTS is not set. ` +
|
|
287
|
+
"All requests will be rejected with 403. Set MCP_HTTP_ALLOWED_HOSTS=host1,host2,... to accept.");
|
|
288
|
+
}
|
|
289
|
+
// Codex round 2 HIGH 1 fix: shutdown 開始後は keep-alive 経由の新規 request を 503
|
|
290
|
+
// で返し、 drain 中に処理継続する race を 構造的に塞ぐ。 flag は handler / shutdown
|
|
291
|
+
// 両方から参照するので runHttp の topmost に置く。
|
|
292
|
+
let isShuttingDown = false;
|
|
293
|
+
const httpServer = createServer((req, res) => {
|
|
294
|
+
if (isShuttingDown) {
|
|
295
|
+
res.setHeader("Connection", "close");
|
|
296
|
+
sendJson(res, 503, { error: "server is shutting down" });
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
applyCorsHeaders(req, res);
|
|
300
|
+
if (req.method === "OPTIONS") {
|
|
301
|
+
// Codex round 2 MEDIUM 3 fix: CORS preflight 厳格化。 Origin 不許可 / 要求
|
|
302
|
+
// method が allowlist 外 / 要求 header が allowlist 外 なら 403 で 明示拒否。
|
|
303
|
+
if (!isPreflightAllowed(req)) {
|
|
304
|
+
sendJson(res, 403, { error: "cors preflight rejected" });
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
res.writeHead(204);
|
|
308
|
+
res.end();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const path = req.url?.split("?")[0] ?? "/";
|
|
312
|
+
if (path === "/health") {
|
|
313
|
+
sendJson(res, 200, {
|
|
314
|
+
status: "ok",
|
|
315
|
+
name: SERVER_NAME,
|
|
316
|
+
version: SERVER_VERSION,
|
|
317
|
+
});
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (path === "/mcp") {
|
|
321
|
+
void handleMcpRequest(req, res).catch((err) => {
|
|
322
|
+
// eslint-disable-next-line no-console
|
|
323
|
+
console.error("[argosvix-mcp/http] unhandled error:", err);
|
|
324
|
+
sendJson(res, 500, { error: "internal server error" });
|
|
325
|
+
});
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
sendJson(res, 404, { error: "not found" });
|
|
329
|
+
});
|
|
330
|
+
// Codex HIGH 1 fix: socket tracking で shutdown 時の force close path を持つ
|
|
331
|
+
const openSockets = new Set();
|
|
332
|
+
httpServer.on("connection", (socket) => {
|
|
333
|
+
openSockets.add(socket);
|
|
334
|
+
socket.once("close", () => openSockets.delete(socket));
|
|
335
|
+
});
|
|
336
|
+
// Codex MEDIUM 4 fix: listen() の error を Promise reject に carry
|
|
337
|
+
await new Promise((resolve, reject) => {
|
|
338
|
+
const onError = (err) => {
|
|
339
|
+
// eslint-disable-next-line no-console
|
|
340
|
+
console.error(`[argosvix-mcp] HTTP server failed to listen on ${HOST}:${PORT}: ${err.code ?? ""} ${err.message}`);
|
|
341
|
+
reject(err);
|
|
342
|
+
};
|
|
343
|
+
httpServer.once("error", onError);
|
|
344
|
+
httpServer.listen(PORT, HOST, () => {
|
|
345
|
+
httpServer.off("error", onError);
|
|
346
|
+
// Codex round 2 MEDIUM 2 fix: listen success 後に発生する error イベントを
|
|
347
|
+
// 常設 handler で受け、 process crash 経路 (= 未処理 error → uncaught exception
|
|
348
|
+
// → 即落ち) を防ぐ。 重大エラーなら shutdown を試みる。
|
|
349
|
+
httpServer.on("error", (err) => {
|
|
350
|
+
// eslint-disable-next-line no-console
|
|
351
|
+
console.error("[argosvix-mcp] http server error event:", err);
|
|
352
|
+
if (!isShuttingDown)
|
|
353
|
+
shutdown(`error:${err.code ?? "unknown"}`);
|
|
354
|
+
});
|
|
355
|
+
// eslint-disable-next-line no-console
|
|
356
|
+
console.error(`[argosvix-mcp] ${SERVER_NAME}@${SERVER_VERSION} HTTP transport ready on http://${HOST}:${PORT}/mcp`);
|
|
357
|
+
resolve();
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
// Codex HIGH 1 fix: shutdown は flag で 1 度限定、 grace period 後 force close
|
|
361
|
+
const shutdown = (signal) => {
|
|
362
|
+
if (isShuttingDown)
|
|
363
|
+
return;
|
|
364
|
+
isShuttingDown = true;
|
|
365
|
+
// eslint-disable-next-line no-console
|
|
366
|
+
console.error(`[argosvix-mcp] received ${signal}, shutting down...`);
|
|
367
|
+
let exited = false;
|
|
368
|
+
const exit = (code) => {
|
|
369
|
+
if (exited)
|
|
370
|
+
return;
|
|
371
|
+
exited = true;
|
|
372
|
+
process.exit(code);
|
|
373
|
+
};
|
|
374
|
+
// Codex round 2 HIGH 1 fix 補足: idle keep-alive socket を即座に閉じて drain を
|
|
375
|
+
// 早める (Node 20+)。 active socket は grace period で待つ。
|
|
376
|
+
httpServer.closeIdleConnections?.();
|
|
377
|
+
httpServer.close((err) => {
|
|
378
|
+
if (err) {
|
|
379
|
+
// eslint-disable-next-line no-console
|
|
380
|
+
console.error("[argosvix-mcp] close error:", err);
|
|
381
|
+
exit(1);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
exit(0);
|
|
385
|
+
});
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
// eslint-disable-next-line no-console
|
|
388
|
+
console.error(`[argosvix-mcp] grace period (${SHUTDOWN_GRACE_MS}ms) expired, force closing ${openSockets.size} socket(s)`);
|
|
389
|
+
for (const s of openSockets) {
|
|
390
|
+
try {
|
|
391
|
+
s.destroy();
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
// ignore
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
exit(1);
|
|
398
|
+
}, SHUTDOWN_GRACE_MS).unref();
|
|
399
|
+
};
|
|
400
|
+
process.once("SIGTERM", () => shutdown("SIGTERM"));
|
|
401
|
+
process.once("SIGINT", () => shutdown("SIGINT"));
|
|
402
|
+
}
|
|
403
|
+
// Allow standalone execution: `node dist/http.js`
|
|
404
|
+
const invokedDirectly = typeof process !== "undefined" &&
|
|
405
|
+
Array.isArray(process.argv) &&
|
|
406
|
+
process.argv[1] !== undefined &&
|
|
407
|
+
/http\.(c?js|mjs)$/.test(process.argv[1]);
|
|
408
|
+
if (invokedDirectly) {
|
|
409
|
+
await runHttp();
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,YAAY,GAGb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EACL,qBAAqB,EACrB,sBAAsB,G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
@@ -5,32 +5,38 @@
|
|
|
5
5
|
* AI agent (= Claude Desktop / Cursor / Codex CLI 等) から Argosvix の
|
|
6
6
|
* traces / cost / alert を 直接 query するための Model Context Protocol server。
|
|
7
7
|
*
|
|
8
|
-
* Phase 1 (= 2026-05
|
|
9
|
-
* - stdio transport のみ (= MCP standard、 Claude Desktop / Cursor 標準)
|
|
10
|
-
* - read-only tools (= query_calls / get_cost_summary / list_alerts)
|
|
11
|
-
* - auth = ARGOSVIX_API_KEY env var 経由
|
|
12
|
-
*
|
|
8
|
+
* Phase 1 (= 2026-05): stdio transport + read-only tools 3 件
|
|
13
9
|
* Phase 2 (= 完了): 書き込み tools (= silence_alert / unsilence_alert)
|
|
14
|
-
* Phase 3 (= 完了):
|
|
10
|
+
* Phase 3 (= 完了): create_alert + read tools 2 件 (get_alert / list_alert_events)
|
|
11
|
+
* + HTTP transport (= 本ファイル + http.ts、 2026-05-31)
|
|
15
12
|
*
|
|
16
|
-
*
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
*
|
|
13
|
+
* 起動モード:
|
|
14
|
+
* - stdio (= default): argosvix-mcp
|
|
15
|
+
* Claude Desktop / Cursor / Codex CLI が subprocess として spawn する想定。
|
|
16
|
+
* ARGOSVIX_API_KEY env var が必須。
|
|
17
|
+
* - HTTP transport: argosvix-mcp --http
|
|
18
|
+
* remote MCP server として port (default 3000) で listen。 認証は各 request の
|
|
19
|
+
* Authorization: Bearer header から。 multi-tenant 用途、 self-host 用。
|
|
20
|
+
* env: MCP_HTTP_PORT / MCP_HTTP_HOST / MCP_HTTP_ALLOWED_HOSTS。
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* stdio install + use (= Claude Desktop の場合):
|
|
22
23
|
* 1. npm install -g @argosvix/mcp-server
|
|
23
|
-
* 2. Claude Desktop
|
|
24
|
+
* 2. Claude Desktop config (= `~/Library/Application Support/Claude/claude_desktop_config.json`)
|
|
24
25
|
* に 以下を追記:
|
|
25
26
|
* {
|
|
26
27
|
* "mcpServers": {
|
|
27
28
|
* "argosvix": {
|
|
28
29
|
* "command": "argosvix-mcp",
|
|
29
|
-
* "env": { "ARGOSVIX_API_KEY": "
|
|
30
|
+
* "env": { "ARGOSVIX_API_KEY": "argk_..." }
|
|
30
31
|
* }
|
|
31
32
|
* }
|
|
32
33
|
* }
|
|
33
34
|
* 3. Claude Desktop 再起動 → tools として 自動認識される
|
|
35
|
+
*
|
|
36
|
+
* HTTP install + use:
|
|
37
|
+
* 1. npm install -g @argosvix/mcp-server (= 同パッケージ)
|
|
38
|
+
* 2. argosvix-mcp --http # localhost:3000/mcp で listen
|
|
39
|
+
* 3. client は POST /mcp に Authorization: Bearer <key> + JSON-RPC body
|
|
34
40
|
*/
|
|
35
41
|
export {};
|
|
36
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG"}
|