railyard-mcp (stdio, MCP TypeScript SDK) with seven tools, all marked read-only for the agent: - deploy.run returns the exact npx railyard deploy command (login first when signed out); the deploy itself runs on the user's machine. - deploy.list and usage.current read the console API with the org token saved by railyard login; a token only ever sees its own org. - insights.summary and insights.funnel say no_data_yet until an Insights query store is configured (RYP-D2), then pass its numbers. - flags.list reports arriving and lists nothing. - gateway.traces reads /relay/traces (RY-RL3) with the gateway key in the environment; Relay limits it to that key's own calls. Arguments are schema-checked; errors are explicit, never an empty success; no token appears in any output. packages/skills: a Claude Code plugin (manifest starting railyard-mcp) with a railyard skill (deploy, Cloudflare login in the browser, rollback, no invented numbers) and a README. Tests: annotation linter over tools/list, org A/B isolation against the real console token and deploy code, signed-out and expired paths, insights and gateway paths, a stdio round trip, and the copy lint over both READMEs, the skill and every tool string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
// The published entry point speaks MCP over stdio.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { spawn } from "node:child_process";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const BIN = join(dirname(fileURLToPath(import.meta.url)), "../bin/railyard-mcp.mjs");
|
|
|
|
test("initialize and tools/list over stdio", async () => {
|
|
const child = spawn(process.execPath, [BIN], { stdio: ["pipe", "pipe", "inherit"], env: { ...process.env, RAILYARD_CONFIG_DIR: "/nonexistent" } });
|
|
const lines = [];
|
|
let buf = "";
|
|
child.stdout.on("data", (d) => {
|
|
buf += d;
|
|
let i;
|
|
while ((i = buf.indexOf("\n")) >= 0) {
|
|
lines.push(JSON.parse(buf.slice(0, i)));
|
|
buf = buf.slice(i + 1);
|
|
}
|
|
});
|
|
const send = (m) => child.stdin.write(`${JSON.stringify(m)}\n`);
|
|
send({ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "t", version: "1" } } });
|
|
send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
send({ jsonrpc: "2.0", id: 2, method: "tools/list" });
|
|
for (let i = 0; i < 100 && lines.length < 2; i += 1) await new Promise((r) => setTimeout(r, 50));
|
|
child.kill();
|
|
assert.equal(lines[0].result.serverInfo.name, "railyard");
|
|
assert.equal(lines[1].result.tools.length, 7);
|
|
});
|