Skip to content

AI and MCP

Tugkan Boz edited this page Jun 4, 2026 · 1 revision

AI and MCP

These features are optional. They talk to LLM providers over the native fetch with your own API key, so the core stays dependency free. Import from two-go/ai.

Generate tests

Draft a suite from a live endpoint or a sample response:

export OPENAI_API_KEY=sk-...
two-go ai gen https://api.example.com/users -o test/users.twogo.mjs
import { aiGenerateTests } from "two-go/ai";
const code = await aiGenerateTests({
  endpoint: "/users",
  baseUrl: "https://api.example.com",
  sample: { data: [{ id: 1, name: "Ada" }] },
  provider: "openai", // or "anthropic", or a custom { baseURL } for a local model
});

The output is a normal *.twogo.mjs file, so it goes into git and runs in CI.

Explain a failure

import { explainFailure } from "two-go/ai";
try {
  await api.get("/users").expectStatus(200);
} catch (err) {
  console.log(await explainFailure(err, { response: err.response, provider: "openai" }));
}

Hunt for bugs

import { aiReview, aiFuzz } from "two-go/ai";

const findings = await aiReview(await api.get("/me"), { provider: "openai" });
// [{ severity, field, message }] e.g. a leaked token or a wrong type

const payloads = await aiFuzz({ endpoint: "/users", method: "POST", schema });
for (const body of payloads) {
  const r = await api.post("/users").json(body);
  if (r.status >= 500) console.log("possible bug:", body, r.status);
}

Both are advisory. Default models are gpt-5.3 (OpenAI) and claude-opus-4-8 (Anthropic), overridable with { model }.

MCP server

two-go ships an MCP server so an agent (Claude and others) can drive it. It is a local stdio server, no URL or key. Install once and the two-go-mcp command is on your PATH:

npm install -g two-go

Claude Code:

claude mcp add two-go two-go-mcp

Or the JSON config most clients use (Claude Desktop, Cursor, Windsurf, Copilot CLI, Kiro):

{ "mcpServers": { "two-go": { "command": "two-go-mcp" } } }

Tools: http_request, gen_openapi, gen_postman, infer_schema, validate_schema.

Clone this wiki locally