AgentSpec
Compiles OpenAPI specifications into AWS Bedrock Action Groups and AWS CDK constructs, and provides a local Bedrock Lambda fulfillment emulator.
Generates Google Gemini Function Declarations from OpenAPI specifications for use with Gemini models.
Generates OpenAI Function Calling schemas from OpenAPI specifications for use with OpenAI models.
Generates Terraform HCL resource blocks for AWS Bedrock Action Groups, enabling infrastructure-as-code deployment.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AgentSpeccall the listPets operation with limit 10"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Overview
Connecting autonomous AI agents to enterprise APIs requires converting OpenAPI documentation into formats that large language models and cloud orchestrators accept. This transition creates three operational problems:
Context overhead: Standard OpenAPI 3.0, 3.1, and Swagger 2.0 documents contain documentation titles, redundant examples, XML metadata, and internal vendor extensions that increase token consumption.
Slow Lambda fulfillment feedback loops: AWS Bedrock Action Groups invoke Lambda functions using an envelope format (
messageVersion: "1.0"). Verifying handler behavior traditionally requires deploying code to AWS and triggering calls through the AWS Management Console.Runtime validation regressions: Models can pass strings where integers are expected, miss required parameters, or invent enum values. Handlers that lack strict assertion logic crash silently in production.
AgentSpec compiles OpenAPI schemas into clean Claude tools and Bedrock Action Groups, provides a local Lambda fulfillment emulator with an interactive web studio, and generates automated boundary test matrices to catch parameter validation regressions locally.
Related MCP server: HiMCP
Key capabilities
Multi-target compilation: Generates Anthropic Claude tool definitions, OpenAI Function Calling schemas, Google Gemini Function Declarations, Model Context Protocol (MCP) tool sets, AWS Bedrock Action Group schemas, AWS CDK TypeScript constructs, Terraform HCL resource blocks, and runtime Zod validation schemas.
Token pruning engine: Removes redundant documentation strings, examples, titles, and internal vendor extensions while preserving schema constraints, reducing prompt token footprints by 40% to 60%.
Local Bedrock Lambda fulfillment emulator: Runs TypeScript and JavaScript Lambda handlers locally without AWS deployment. The emulator synthesizes authentic
messageVersion: "1.0"event envelopes and records execution duration and console logs.Autonomous zero-code mock mode: Generates realistic, schema-valid synthetic mock responses directly from OpenAPI 3.0 response schemas when handler implementations are not yet written.
Stateful multi-turn session persistence: Tracks and accumulates
sessionAttributesandpromptSessionAttributesacross multiple tool calls within an agent conversation.Breaking change detector: Scans schema diffs to identify removed operations, newly introduced required parameters, altered data types, and deleted enum values before changes reach production agents.
MCP stdio server bridge: Exposes your local Lambda fulfillment handler as a native Model Context Protocol server over standard input and output.
Interactive browser studio: Built-in 3-column web interface running on localhost for inspecting endpoints, executing parameter payloads, and viewing real-time schema validation diagnostics.
Automated boundary and fuzzing suite: Generates baseline happy paths, type mismatch violations, missing required parameters, and enum boundary conditions to verify that Lambda handlers return proper HTTP 4xx errors instead of unhandled exceptions.
Project scaffolder: Bootstraps complete, production-ready TypeScript projects with pre-wired handlers, typed schemas, and configuration files via
agentspec init.
Installation
Install globally via npm or run directly through npx:
npm install -g agentspecOr run via npx:
npx agentspec --helpQuickstart
1. Inspect an OpenAPI specification
Inspect endpoint count, parameter depth, and estimated token savings:
agentspec inspect ./petstore.json OpenAPI Inspection: Swagger Petstore (v1.0.0)
Sample Petstore API for AgentSpec testing
┌──────────────────────────────┬──────────────────────────────┐
│ Metric │ Value │
├──────────────────────────────┼──────────────────────────────┤
│ Total Operations │ 4 │
│ Total Path Routes │ 2 │
│ Original Token Estimate │ 771 │
│ Pruned Token Estimate │ 385 │
│ Estimated Token Savings │ 50.1% │
└──────────────────────────────┴──────────────────────────────┘2. Compile to Claude Tools and AWS Bedrock
Compile your OpenAPI specification into all supported target artifacts:
agentspec compile ./petstore.json --target all --output ./outputGenerated artifacts in ./output:
claude-tools.json: Anthropic Claude tool definitions ready for the Messages API.bedrock-action-group.json: AWS Bedrock Action Group configuration payload.bedrock-openapi.json: Compliant OpenAPI 3.0.0 schema slice for Bedrock.bedrock-cdk.ts: AWS CDK TypeScript construct usingaws-cdk-lib/aws-bedrock.bedrock.tf: Terraform HCL definition usingaws_bedrockagent_agent_action_group.types.tsandschemas.ts: TypeScript interfaces and runtime Zod schemas.
3. Run the local Bedrock Lambda emulator
Start the local fulfillment emulator pointing to your local TypeScript handler file:
agentspec simulate ./petstore.json --handler ./src/lambda.ts --port 5005Open http://localhost:5005/_studio in your browser to access the visual testing studio. You can also trigger endpoints directly via HTTP requests:
# Direct REST invocation
curl http://localhost:5005/pets/1
# Explicit tool invocation
curl -X POST http://localhost:5005/api/invoke \
-H "Content-Type: application/json" \
-d '{"operationId": "getPetById", "parameters": {"petId": 1}}'4. Run automated boundary and fuzzing tests
Verify that your Lambda handler rejects invalid requests with proper HTTP 400 responses:
agentspec test ./petstore.json --handler ./src/lambda.ts5. Run autonomous zero-code mock server
Simulate complete agent tool calls before writing any handler code:
agentspec mock ./petstore.json --port 5005The mock engine returns schema-valid synthetic mock data for every operation, allowing frontend and agent developers to build against the API contract immediately.
6. Detect breaking schema changes
Audit OpenAPI schema updates for breaking changes that break agent tool calling:
agentspec diff ./baseline-spec.json ./candidate-spec.json --fail-on-breakingDetects removed operations, newly added required parameters, altered parameter data types, and deleted enum values.
7. Run as Model Context Protocol (MCP) server
Connect your Lambda fulfillment handler directly to Claude Desktop, Cursor, or any MCP client over standard I/O:
agentspec mcp ./petstore.json --handler ./src/lambda.ts8. Scaffold a complete project
Initialize a new project with pre-wired TypeScript handler, types, and npm scripts:
agentspec init --dir ./my-agentLambda fulfillment contract
AWS Bedrock sends events formatted with messageVersion: "1.0". Your handler receives the event and returns a response containing a serialized JSON string in the responseBody object.
Event envelope (BedrockLambdaEvent)
export interface BedrockLambdaEvent {
messageVersion: '1.0';
agent: {
name: string;
id: string;
alias: string;
version: string;
};
actionGroup: string;
apiPath: string;
httpMethod: string;
parameters: Array<{
name: string;
type: string;
value: string;
}>;
requestBody?: {
content: {
'application/json': {
properties: Array<{
name: string;
type: string;
value: unknown;
}>;
};
};
};
sessionAttributes: Record<string, string>;
promptSessionAttributes: Record<string, string>;
inputText?: string;
}Response structure (BedrockLambdaResponse)
export interface BedrockLambdaResponse {
messageVersion: '1.0';
response: {
actionGroup: string;
apiPath: string;
httpMethod: string;
httpStatusCode: number;
responseBody: {
'application/json': {
body: string; // Must be a serialized JSON string
};
};
};
sessionAttributes?: Record<string, string>;
promptSessionAttributes?: Record<string, string>;
}Writing a compliant TypeScript handler
import type { BedrockLambdaEvent, BedrockLambdaResponse } from 'agentspec';
export const handler = async (event: BedrockLambdaEvent): Promise<BedrockLambdaResponse> => {
const { apiPath, httpMethod, parameters, actionGroup } = event;
if (apiPath === '/pets' && httpMethod === 'GET') {
return {
messageVersion: '1.0',
response: {
actionGroup,
apiPath,
httpMethod,
httpStatusCode: 200,
responseBody: {
'application/json': {
body: JSON.stringify([
{ id: 1, name: 'Fido', status: 'available' }
])
}
}
}
};
}
return {
messageVersion: '1.0',
response: {
actionGroup,
apiPath,
httpMethod,
httpStatusCode: 404,
responseBody: {
'application/json': {
body: JSON.stringify({ message: 'Resource not found' })
}
}
}
};
};CLI command reference
Command | Arguments | Options | Description |
|
|
| Scaffolds a complete TypeScript project with handler, types, and configs. |
|
|
| Compiles OpenAPI schemas into Claude, OpenAI, Gemini, MCP, Bedrock, CDK, and Terraform definitions. |
|
|
| Starts local fulfillment emulator and interactive testing studio at |
|
|
| Starts autonomous mock server with schema-conforming synthetic responses (zero code). |
|
|
| Runs automated schema boundary and fuzzing test cases against the local Lambda handler. |
|
|
| Detects breaking changes in OpenAPI specs that disrupt agent tool calling. |
|
|
| Runs Model Context Protocol (MCP) server over standard I/O (stdio). |
|
| None | Analyzes OpenAPI operations, parameter complexity, and calculates token savings. |
Programmatic API
AgentSpec can be imported as a TypeScript library:
import {
Compiler,
BedrockEnvelope,
ResponseValidator,
MockServer,
FuzzRunner
} from 'agentspec';
// 1. Compile spec programmatically
const artifacts = Compiler.compile('./petstore.json', {
target: 'all',
prune: true
});
// 2. Synthesize Bedrock events
const event = BedrockEnvelope.synthesize(operation, { petId: 10 });
// 3. Validate Lambda output against OpenAPI response schema
const validation = ResponseValidator.validate(event, lambdaOutput, operation);
if (!validation.isValid) {
console.error(validation.errors);
}Architecture
AgentSpec operates as a modular compiler pipeline:
[ OpenAPI 3.0 / 3.1 / Swagger 2.0 ]
│
▼
┌─────────────────────────────────┐
│ OpenAPILoader │ Parses JSON/YAML, normalizes Swagger 2.0,
│ Dereferencer & Cycle Breaker │ resolves $ref pointers without recursion traps.
└────────────────┬────────────────┘
│
▼
┌─────────────────────────────────┐
│ SchemaPruner │ Strips titles, examples, and internal extensions.
│ Token Optimization Engine │ Computes exact context reduction metrics.
└────────────────┬────────────────┘
│
┌─────────────┴─────────────┐
▼ ▼
┌──────────────────┐ ┌────────────────────────┐
│ ClaudeCompiler │ │ BedrockCompiler │
│ Anthropic Tools │ │ Action Groups & IaC │
└──────────────────┘ └────────────────────────┘See docs/ARCHITECTURE.md for technical details on schema normalization, circular reference resolution, and event envelope generation.
Contributing
Clone the repository:
git clone https://github.com/alexandrmotologa/agentspec.gitInstall dependencies:
npm installRun the test suite:
npm testBuild the project:
npm run build
License
MIT License. Copyright (c) 2026 Alexandr Motologa.
This server cannot be deployed
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
MCP server (stdio): lint OpenAPI specs with Spectral via the AgentForge API
- TypeshipOAuthdev.typeship
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
Ovanek MCP: Model Context Protocol server for Ovanek platform tools; writes are dry-run by default.
Related MCP Servers
- AlicenseBqualityDmaintenanceA minimal local MCP server that wraps any Claude Messages API-compatible upstream into a unified ask_model tool. It enables MCP clients to interact with these models through a standard tool interface using stdio transport.18MIT
- AlicenseNot gradedqualityCmaintenanceCompiles OpenAPI 3.x documents and HTTP manifests into verified MCP tools, serving only operator-approved HTTP operations over Model Context Protocol stdio.Apache 2.0
- FlicenseCqualityBmaintenanceSchema-driven MCP server that exposes all Paperclip API operations as typed MCP tools over stdio or Streamable HTTP, supporting both authenticated and local_mode deployments.100-
- AlicenseNot gradedqualityBmaintenanceServes any OpenAPI 3.x/Swagger 2.x API as a local MCP server over stdio, converting every operation into a tool that proxies requests to the upstream API with configurable headers and fixed parameters.5 npm1MIT