Claude Agent SDK Integration
Use CoreValue AI Gateway with the Claude Agent SDK for building AI agents with automatic observability
Introduction
The Claude Agent SDK allows you to build powerful AI agents that can use tools and make decisions autonomously.
This integration uses CoreValue's Model Context Protocol (MCP) to provide seamless AI Gateway access to your Claude agents.
The @cova/mcp package is a Claude Desktop / Agent SDK integration tool that is shipped today.
This is separate from the MCP Gateway (proxy, logging, registry, governance) which is on the
Roadmap for M5–M7 and is not yet shipped.
Integration Steps
Sign up at corevalue.dev and generate an API key.
Make sure to have some credits available in your CoreValue account to make requests (or BYOK).
npm install @cova/mcpyarn add @cova/mcppnpm add @cova/mcpAdd to your Claude Desktop configuration:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"corevalue": {
"command": "npx",
"args": ["@cova/mcp@latest"],
"env": {
"COVA_API_KEY": "sk-cova-XXXXXXXXXXXXXXXX"
}
}
}
}The CoreValue MCP tools will be automatically available in Claude Desktop.
import { query } from '@anthropic-ai/claude-agent-sdk';
// Make a query with CoreValue MCP
const result = await query({
prompt: 'Use the use_ai_gateway tool to ask GPT-4o: "What is CoreValue?"',
options: {
mcpServers: {
corevalue: {
command: 'npx',
args: ['@cova/mcp'],
env: {
COVA_API_KEY: process.env.COVA_API_KEY
}
}
},
// Explicitly allow CoreValue MCP tools (recommended for production)
allowedTools: [
'mcp__corevalue__use_ai_gateway',
'mcp__corevalue__query_requests',
'mcp__corevalue__query_sessions'
]
}
});
// Extract the response
for await (const message of result.sdkMessages) {
if (message.type === 'result' && message.result) {
console.log('Response:', message.result);
}
}import { query } from '@anthropic-ai/claude-agent-sdk';
const result = await query({
prompt: 'Use the use_ai_gateway tool to generate a creative story about AI using gpt-4o with temperature 0.8',
options: {
mcpServers: {
corevalue: {
command: 'npx',
args: ['@cova/mcp'],
env: {
COVA_API_KEY: process.env.COVA_API_KEY
}
}
},
allowedTools: ['mcp__corevalue__use_ai_gateway']
}
});
// Get the response
for await (const message of result.sdkMessages) {
if (message.type === 'result' && message.result) {
console.log(message.result);
}
}The agent will automatically use the use_ai_gateway tool to make the request through CoreValue AI Gateway.
Available MCP Tools
use_ai_gateway
Make requests to any LLM provider through CoreValue AI Gateway with automatic observability.
Parameters:
model(required): Model name (e.g.,gpt-4o,anthropic/claude-sonnet-4,google/gemini-2.0-flash- see Supported Models for more)messages(required): Array of conversation messagesmax_tokens(optional): Maximum tokens to generatetemperature(optional): Response randomness (0-2)sessionId(optional): Session ID for request groupingsessionName(optional): Human-readable session nameuserId(optional): User identifier for trackingcustomProperties(optional): Custom metadata for filtering
query_requests
Query historical requests for debugging and analysis with filters, pagination, and sorting.
query_sessions
Query conversation sessions with filtering, search, and time range capabilities.
Complete Working Examples
Basic Agent with Session Tracking
import { query } from '@anthropic-ai/claude-agent-sdk';
// Configure MCP server
const mcpConfig = {
corevalue: {
command: 'npx',
args: ['@cova/mcp'],
env: {
COVA_API_KEY: process.env.COVA_API_KEY
}
}
};
// Make a request with session tracking
const sessionId = `chat-${Date.now()}`;
const result = await query({
prompt: `Use the use_ai_gateway tool to ask Claude Sonnet: "Plan a 3-day trip to Japan"
Use these settings:
- sessionId: "${sessionId}"
- sessionName: "travel-planning"
- customProperties: {"topic": "travel", "destination": "japan"}`,
options: {
mcpServers: mcpConfig,
allowedTools: ['mcp__corevalue__use_ai_gateway']
}
});
// Extract response
for await (const message of result.sdkMessages) {
if (message.type === 'result' && message.result) {
console.log('Travel Plan:', message.result);
}
}Multi-Model Comparison
import { query } from '@anthropic-ai/claude-agent-sdk';
const sessionId = `comparison-${Date.now()}`;
const result = await query({
prompt: `Compare responses from multiple models on: "Explain quantum computing in simple terms"
1. Use GPT-4o-mini (fast, cost-effective)
2. Use Claude Sonnet (high quality)
3. Use GPT-4o (balanced)
Use sessionId: "${sessionId}" for all requests so I can compare them later.`,
options: {
mcpServers: {
corevalue: {
command: 'npx',
args: ['@cova/mcp'],
env: {
COVA_API_KEY: process.env.COVA_API_KEY
}
}
},
allowedTools: ['mcp__corevalue__use_ai_gateway']
}
});
// Get comparison results
for await (const message of result.sdkMessages) {
if (message.type === 'result') {
console.log('Comparison:', message.result);
}
}Self-Analyzing Agent
import { query } from '@anthropic-ai/claude-agent-sdk';
const result = await query({
prompt: `Perform a task and then analyze your own performance:
1. Use the use_ai_gateway tool to generate a haiku about AI
2. Then use query_requests to check how much the request cost
3. Use query_sessions to see your recent activity
4. Provide a summary of your performance and costs`,
options: {
mcpServers: {
corevalue: {
command: 'npx',
args: ['@cova/mcp'],
env: {
COVA_API_KEY: process.env.COVA_API_KEY
}
}
},
allowedTools: [
'mcp__corevalue__use_ai_gateway',
'mcp__corevalue__query_requests',
'mcp__corevalue__query_sessions'
]
}
});
// Get self-analysis
for await (const message of result.sdkMessages) {
if (message.type === 'result') {
console.log('Self-Analysis:', message.result);
}
}