@machinegrade/validate
Advanced tools
| /** | ||
| * Shared MCP tool metadata for "validate". Used by both the stdio adapter | ||
| * (mcp/server.ts, forwards to a possibly-remote HTTP API) and the in-process | ||
| * remote MCP endpoint (src/mcpServer.ts, POST /mcp) — one definition so the | ||
| * two transports can't drift out of sync. | ||
| */ | ||
| export const VALIDATE_TOOL = { | ||
| name: "validate", | ||
| description: "Validate an artifact against a contract (json_schema | openapi_response | sql) via the machinegrade validate API.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| type: { | ||
| type: "string", | ||
| enum: ["json_schema", "openapi_response", "sql"], | ||
| description: "Which validator to run.", | ||
| }, | ||
| artifact: { | ||
| description: "The artifact to validate (object for json_schema/openapi_response, SQL string for sql).", | ||
| }, | ||
| contract: { | ||
| description: "Validator-specific contract. json_schema: { schema }. openapi_response: { spec, path, method, status }. sql: { dialect }.", | ||
| }, | ||
| }, | ||
| required: ["type", "artifact"], | ||
| }, | ||
| }; |
+21
| MIT License | ||
| Copyright (c) 2026 machinegrade | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+2
-22
@@ -18,26 +18,6 @@ #!/usr/bin/env node | ||
| import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; | ||
| import { VALIDATE_TOOL } from "../src/validateTool.js"; | ||
| const SANDBOX_URL = process.env.SANDBOX_URL ?? "https://api.machinegrade.dev"; | ||
| const VALIDATE_TOOL = { | ||
| name: "validate", | ||
| description: "Validate an artifact against a contract (json_schema | openapi_response | sql) via the machinegrade validate HTTP API's POST /v1/validate.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| type: { | ||
| type: "string", | ||
| enum: ["json_schema", "openapi_response", "sql"], | ||
| description: "Which validator to run.", | ||
| }, | ||
| artifact: { | ||
| description: "The artifact to validate (object for json_schema/openapi_response, SQL string for sql).", | ||
| }, | ||
| contract: { | ||
| description: "Validator-specific contract. json_schema: { schema }. openapi_response: { spec, path, method, status }. sql: { dialect }.", | ||
| }, | ||
| }, | ||
| required: ["type", "artifact"], | ||
| }, | ||
| }; | ||
| function buildServer() { | ||
| const server = new Server({ name: "machinegrade-validate-mcp", version: "0.1.0" }, { capabilities: { tools: {} } }); | ||
| const server = new Server({ name: "machinegrade-validate-mcp", version: "0.1.1" }, { capabilities: { tools: {} } }); | ||
| server.setRequestHandler(ListToolsRequestSchema, async () => ({ | ||
@@ -44,0 +24,0 @@ tools: [VALIDATE_TOOL], |
+2
-2
| { | ||
| "name": "@machinegrade/validate", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "description": "Deterministic validation of AI-generated artifacts: JSON Schema conformance, OpenAPI response conformance, SQL syntax. Metered API + MCP adapter with typed verdicts and fix hints.", | ||
@@ -17,3 +17,3 @@ "type": "module", | ||
| }, | ||
| "files": ["dist/mcp", "README.md"], | ||
| "files": ["dist/mcp", "dist/src", "README.md"], | ||
| "publishConfig": { | ||
@@ -20,0 +20,0 @@ "access": "public" |
+40
-4
@@ -102,2 +102,26 @@ # machinegrade validate | ||
| ## Connect remotely | ||
| The production service also exposes an MCP endpoint directly — no local | ||
| process, no npm install — via streamable HTTP at: | ||
| ``` | ||
| POST https://api.machinegrade.dev/mcp | ||
| ``` | ||
| It's the same single `validate` tool as the stdio adapter above. | ||
| `initialize` and `tools/list` work without a key (discovery is | ||
| anonymous); `tools/call` requires `X-Api-Key` (issue one via `POST | ||
| /keys`, same as the REST API — the free tier and limits are shared). | ||
| With Claude Code: | ||
| ```bash | ||
| claude mcp add --transport http validate https://api.machinegrade.dev/mcp --header "X-Api-Key: sk_..." | ||
| ``` | ||
| The stdio adapter via npm (`@machinegrade/validate`, see above) remains | ||
| available for local/offline use or clients without HTTP transport | ||
| support. | ||
| ## API | ||
@@ -118,2 +142,3 @@ | ||
| | `GET /openapi.yaml`, `GET /llms.txt` | — | static docs | | ||
| | `POST /mcp` | MCP streamable HTTP, header `X-Api-Key` for `tools/call` | see "Connect remotely" above | | ||
@@ -201,6 +226,17 @@ ## Pricing | ||
| ## Kill criteria | ||
| ## Status | ||
| This is a demand-test sandbox for one experiment (see `../experiments/EXP-001-output-validation.md`). | ||
| It's built to be disposable: if the experiment doesn't show demand, delete | ||
| this directory without ceremony. | ||
| Early stage, honestly so: this service is live and free-tier usage is real, | ||
| and we're measuring whether it earns a paid tier. What you can rely on: | ||
| - The API contract (`/v1/validate` request/response shapes, typed error | ||
| codes, verdict semantics) is stable — breaking changes only with a | ||
| versioned path (`/v2/...`), never silently. | ||
| - The free tier (500 calls/month) stays. | ||
| - If we ever sunset the service, keys keep working for 90 days after the | ||
| announcement, and the validators are open source in this repo — you can | ||
| self-host the same behavior. | ||
| Feedback and integration stories are the most valuable thing you can give | ||
| us right now: open an issue or use `POST /v1/paid-request` if you need | ||
| more than the free tier. |
15420
21.86%5
66.67%107
7%240
17.65%