DocumentationAPI Reference

API Reference

Complete reference for the MCPCodex REST API. Integrate AI-powered code generation into your applications with our comprehensive API.

99.9% uptime
Global CDN
SOC 2 compliant

Base URL

https://api.mcpcodex.com

All API requests should be made to this base URL. API version is included in the path.

Authentication

MCPCodex uses API keys to authenticate requests. You can get your API key from the dashboard.

// Include your API key in the Authorization header
Authorization: Bearer YOUR_API_KEY

// Example with curl
curl https://api.mcpcodex.com/api/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY"

Security: Never expose your API key in client-side code. Always make API calls from your backend server.

Endpoints

POST/api/v1/auth/register

Register a new user account

Parameters

  • email
  • password
  • name

Response

{ token, user, expiresIn }
POST/api/v1/auth/login

Authenticate user and get token

Parameters

  • email
  • password

Response

{ token, user, expiresIn }
POST/api/v1/auth/refresh

Refresh authentication token

Parameters

  • refreshToken

Response

{ token, refreshToken, expiresIn }
POST/api/v1/auth/logout

Invalidate current session

Parameters

No parameters required

Response

{ success }

Code Examples

Authentication

// Initialize MCPCodex client
import { MCPCodex } from '@mcpcodex/sdk';

const client = new MCPCodex({
  apiKey: process.env.MCPCODEX_API_KEY
});

// Register a new user
const { token, user } = await client.auth.register({
  email: '[email protected]',
  password: 'securePassword123',
  name: 'John Doe'
});

// Set auth token for subsequent requests
client.setAuthToken(token);

Generate Code

// Generate a React component
const result = await client.generate({
  prompt: 'Create a user profile card component with avatar, name, and bio',
  language: 'typescript',
  context: {
    framework: 'react',
    styling: 'tailwind',
    includeTests: true
  }
});

// Access generated files
result.files.forEach(file => {
  console.log(`Generated: ${file.path}`);
  console.log(file.content);
});

Create and Use Agent

// Create a specialized agent
const agent = await client.agents.create({
  name: 'backend-specialist',
  model: 'gpt-4-turbo',
  config: {
    temperature: 0.7,
    maxTokens: 4096,
    specialization: 'backend-api'
  }
});

// Use the agent for code generation
const response = await agent.execute({
  task: 'Create a REST API for blog posts with CRUD operations',
  requirements: {
    database: 'PostgreSQL',
    framework: 'Express.js',
    authentication: 'JWT'
  }
});

WebSocket Streaming

// Connect to WebSocket for real-time streaming
const ws = client.streaming.connect();

ws.on('connected', () => {
  console.log('Connected to MCPCodex streaming');
});

// Stream code generation
const stream = await client.streaming.generate({
  prompt: 'Build a real-time chat application',
  streamTokens: true
});

stream.on('token', (token) => {
  process.stdout.write(token);
});

stream.on('complete', (result) => {
  console.log('Generation complete:', result);
});

Rate Limits

100
Requests/minute
Free tier
1,000
Requests/minute
Pro tier
Unlimited
Requests/minute
Enterprise

Rate limit headers are included in all responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset

Need Help?

Our team is here to help you integrate MCPCodex into your applications.