Complete reference for the MCPCodex REST API. Integrate AI-powered code generation into your applications with our comprehensive API.
https://api.mcpcodex.com
All API requests should be made to this base URL. API version is included in the path.
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.
/api/v1/auth/register
Register a new user account
email
password
name
{ token, user, expiresIn }
/api/v1/auth/login
Authenticate user and get token
email
password
{ token, user, expiresIn }
/api/v1/auth/refresh
Refresh authentication token
refreshToken
{ token, refreshToken, expiresIn }
/api/v1/auth/logout
Invalidate current session
{ success }
// 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 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 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'
}
});
// 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 limit headers are included in all responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
Our team is here to help you integrate MCPCodex into your applications.