23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
272 lines
9.8 KiB
TypeScript
272 lines
9.8 KiB
TypeScript
/**
|
|
* Tests for http_fetch MCP tool (ADR-164 §5.1.8, Phase 4).
|
|
*
|
|
* Coverage:
|
|
* - URL allowlist (default-blocks file://, ftp://, RFC-1918, loopback, link-local)
|
|
* - Opt-in via CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE=1 reaches a local server
|
|
* - Header sanitization (default-rejects Authorization / Cookie / X-Auth-*)
|
|
* - Opt-in via CLAUDE_FLOW_HTTP_FETCH_ALLOW_AUTH=1 passes the header
|
|
* - Hard timeout aborts via AbortController
|
|
* - Response truncation honours maxResponseBytes
|
|
* - Happy path against a local mock node:http server
|
|
* - Default User-Agent injected if caller did not provide one
|
|
*/
|
|
import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
|
|
import http from 'node:http';
|
|
import type { AddressInfo } from 'node:net';
|
|
|
|
import {
|
|
httpFetchTools,
|
|
httpFetchExecute,
|
|
validateUrl,
|
|
validateHeaders,
|
|
HttpFetchValidationError,
|
|
} from '../src/mcp-tools/http-fetch-tools.js';
|
|
|
|
function findTool(name: string) {
|
|
const t = httpFetchTools.find((x) => x.name === name);
|
|
if (!t) throw new Error(`tool not found: ${name}`);
|
|
return t;
|
|
}
|
|
|
|
// ---------- mock server for happy-path + truncation + timeout tests --------
|
|
|
|
let server: http.Server;
|
|
let port: number;
|
|
let lastUA: string | undefined;
|
|
let lastAuth: string | undefined;
|
|
let lastMethod: string | undefined;
|
|
let lastBody: string | undefined;
|
|
|
|
beforeAll(async () => {
|
|
await new Promise<void>((resolve) => {
|
|
server = http.createServer((req, res) => {
|
|
lastUA = req.headers['user-agent'] as string | undefined;
|
|
lastAuth = req.headers['authorization'] as string | undefined;
|
|
lastMethod = req.method;
|
|
|
|
// Collect body
|
|
const chunks: Buffer[] = [];
|
|
req.on('data', (c) => chunks.push(c));
|
|
req.on('end', () => {
|
|
lastBody = Buffer.concat(chunks).toString('utf-8');
|
|
|
|
const url = req.url ?? '/';
|
|
if (url === '/ok') {
|
|
res.writeHead(200, { 'content-type': 'text/plain', 'x-server': 'mock' });
|
|
res.end('hello-world');
|
|
} else if (url === '/big') {
|
|
// 1MB+ body — should trigger truncation when maxResponseBytes < 1MB
|
|
res.writeHead(200, { 'content-type': 'application/octet-stream' });
|
|
res.end(Buffer.alloc(2 * 1024 * 1024, 0x41));
|
|
} else if (url === '/slow') {
|
|
// Never respond — caller must abort
|
|
// Keep connection open. Don't write headers either.
|
|
// Will be terminated when the test server closes.
|
|
} else if (url === '/echo') {
|
|
res.writeHead(200, { 'content-type': 'application/json' });
|
|
res.end(JSON.stringify({ method: req.method, body: lastBody }));
|
|
} else if (url === '/500') {
|
|
res.writeHead(500, { 'content-type': 'text/plain' });
|
|
res.end('server-error');
|
|
} else {
|
|
res.writeHead(404);
|
|
res.end('not-found');
|
|
}
|
|
});
|
|
});
|
|
server.listen(0, '127.0.0.1', () => {
|
|
port = (server.address() as AddressInfo).port;
|
|
resolve();
|
|
});
|
|
});
|
|
});
|
|
|
|
afterAll(async () => {
|
|
// Force-close to terminate any lingering /slow request
|
|
await new Promise<void>((resolve) => {
|
|
server.closeAllConnections?.();
|
|
server.close(() => resolve());
|
|
});
|
|
});
|
|
|
|
// ---------- env-flag isolation -----------------------------------
|
|
|
|
const originalEnv = { ...process.env };
|
|
beforeEach(() => {
|
|
delete process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE;
|
|
delete process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_AUTH;
|
|
});
|
|
afterEach(() => {
|
|
process.env = { ...originalEnv };
|
|
});
|
|
|
|
// ---------- URL allowlist tests ----------------------------------
|
|
|
|
describe('http_fetch — URL allowlist (default-deny)', () => {
|
|
it('rejects file:// URLs', () => {
|
|
expect(() => validateUrl('file:///etc/passwd')).toThrow(HttpFetchValidationError);
|
|
});
|
|
|
|
it('rejects ftp:// URLs', () => {
|
|
expect(() => validateUrl('ftp://example.com/x')).toThrow(/protocol/);
|
|
});
|
|
|
|
it('rejects localhost', () => {
|
|
expect(() => validateUrl('http://localhost/foo')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('rejects 127.0.0.1', () => {
|
|
expect(() => validateUrl('http://127.0.0.1/foo')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('rejects 10.x RFC1918', () => {
|
|
expect(() => validateUrl('http://10.0.0.5/foo')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('rejects 192.168.x.x RFC1918', () => {
|
|
expect(() => validateUrl('http://192.168.1.1/foo')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('rejects 172.16.x.x RFC1918', () => {
|
|
expect(() => validateUrl('http://172.20.0.1/foo')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('rejects 169.254.x.x link-local', () => {
|
|
expect(() => validateUrl('http://169.254.169.254/latest')).toThrow(/loopback|private/i);
|
|
});
|
|
|
|
it('allows public host (example.com) by hostname check alone', () => {
|
|
expect(() => validateUrl('https://example.com/foo')).not.toThrow();
|
|
});
|
|
|
|
it('opt-in CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE=1 unlocks private addresses', () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
expect(() => validateUrl('http://127.0.0.1/foo')).not.toThrow();
|
|
expect(() => validateUrl('http://10.0.0.5/foo')).not.toThrow();
|
|
});
|
|
});
|
|
|
|
// ---------- header sanitization tests ----------------------------
|
|
|
|
describe('http_fetch — header sanitization (default-deny auth)', () => {
|
|
it('rejects Authorization header by default', () => {
|
|
expect(() => validateHeaders({ Authorization: 'Bearer abc' })).toThrow(/not allowed/i);
|
|
});
|
|
it('rejects Cookie header by default', () => {
|
|
expect(() => validateHeaders({ Cookie: 'sid=abc' })).toThrow(/not allowed/i);
|
|
});
|
|
it('rejects X-Auth-Token by default', () => {
|
|
expect(() => validateHeaders({ 'X-Auth-Token': 'abc' })).toThrow(/not allowed/i);
|
|
});
|
|
it('accepts benign headers', () => {
|
|
const h = validateHeaders({ Accept: 'application/json', 'X-Pod': 'ops' });
|
|
expect(h.Accept).toBe('application/json');
|
|
expect(h['X-Pod']).toBe('ops');
|
|
});
|
|
it('opt-in CLAUDE_FLOW_HTTP_FETCH_ALLOW_AUTH=1 unlocks auth headers', () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_AUTH = '1';
|
|
expect(() => validateHeaders({ Authorization: 'Bearer abc' })).not.toThrow();
|
|
});
|
|
});
|
|
|
|
// ---------- happy path / timeout / truncation --------------------
|
|
|
|
describe('http_fetch — execution path against a mock server', () => {
|
|
it('happy-path GET returns 200 and body', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({ url: `http://127.0.0.1:${port}/ok` });
|
|
expect(result.success).toBe(true);
|
|
expect(result.status).toBe(200);
|
|
expect(result.body).toBe('hello-world');
|
|
expect(result.bodyTruncated).toBe(false);
|
|
});
|
|
|
|
it('default User-Agent is sent when caller omits it', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
lastUA = undefined;
|
|
await httpFetchExecute({ url: `http://127.0.0.1:${port}/ok` });
|
|
expect(lastUA).toMatch(/^ruflo-http-fetch\//);
|
|
});
|
|
|
|
it('aborts on timeout', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({
|
|
url: `http://127.0.0.1:${port}/slow`,
|
|
timeoutMs: 100,
|
|
});
|
|
expect(result.success).toBe(false);
|
|
expect(result.errorCode).toBe('TIMEOUT');
|
|
expect(result.durationMs).toBeGreaterThanOrEqual(80);
|
|
expect(result.durationMs).toBeLessThan(5_000);
|
|
}, 10_000);
|
|
|
|
it('truncates the response when body exceeds maxResponseBytes', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({
|
|
url: `http://127.0.0.1:${port}/big`,
|
|
maxResponseBytes: 1024,
|
|
});
|
|
expect(result.success).toBe(true);
|
|
expect(result.bodyTruncated).toBe(true);
|
|
expect(result.bytesRead).toBeLessThanOrEqual(1024);
|
|
expect(result.body.length).toBeLessThanOrEqual(1024);
|
|
}, 10_000);
|
|
|
|
it('refuses to call when URL is private and flag is off', async () => {
|
|
const result = await httpFetchExecute({ url: `http://127.0.0.1:${port}/ok` });
|
|
expect(result.success).toBe(false);
|
|
expect(result.errorCode).toBe('PRIVATE_ADDRESS');
|
|
});
|
|
|
|
it('refuses Authorization header without env flag', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({
|
|
url: `http://127.0.0.1:${port}/ok`,
|
|
headers: { Authorization: 'Bearer abc' },
|
|
});
|
|
expect(result.success).toBe(false);
|
|
expect(result.errorCode).toBe('FORBIDDEN_HEADER');
|
|
});
|
|
|
|
it('POST with body echoes back through /echo', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({
|
|
url: `http://127.0.0.1:${port}/echo`,
|
|
method: 'POST',
|
|
body: 'hello',
|
|
});
|
|
expect(result.success).toBe(true);
|
|
expect(result.status).toBe(200);
|
|
const parsed = JSON.parse(result.body);
|
|
expect(parsed.method).toBe('POST');
|
|
expect(parsed.body).toBe('hello');
|
|
});
|
|
|
|
it('reports non-2xx status without throwing', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const result = await httpFetchExecute({ url: `http://127.0.0.1:${port}/500` });
|
|
expect(result.success).toBe(true);
|
|
expect(result.status).toBe(500);
|
|
expect(result.body).toBe('server-error');
|
|
});
|
|
});
|
|
|
|
// ---------- MCP tool wiring -------------------------------------
|
|
|
|
describe('http_fetch — MCP tool registration', () => {
|
|
it('exports http_fetch tool with required schema fields', () => {
|
|
const tool = findTool('http_fetch');
|
|
expect(tool.description.length).toBeGreaterThan(80);
|
|
expect(tool.description).toMatch(/Use when/i);
|
|
expect(tool.inputSchema.required).toEqual(['url']);
|
|
});
|
|
|
|
it('tool.handler dispatches to httpFetchExecute', async () => {
|
|
process.env.CLAUDE_FLOW_HTTP_FETCH_ALLOW_PRIVATE = '1';
|
|
const tool = findTool('http_fetch');
|
|
const result = (await tool.handler({ url: `http://127.0.0.1:${port}/ok` })) as { status: number };
|
|
expect(result.status).toBe(200);
|
|
});
|
|
});
|