TypeScript (MCP SDK)
StreamableHTTPClientTransport తో అధికారిక TypeScript MCP SDK (2.3.0 లేదా కొత్తది).
- API కీ (Bearer)
ప్యాకేజీని ఇన్స్టాల్ చేయండి
npm install @modelcontextprotocol/client@^2.3.0
2.3.0 లేదా కొత్తదాన్ని ఉపయోగించండి (రీడైరెక్ట్లలో హెడర్లు మళ్లీ పంపబడే సమస్యకు సెక్యూరిటీ ఫిక్స్).
క్లయింట్ కోడ్
సిఫార్సు చేయబడినవిimport { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
const client = new Client({ name: 'my-app', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('https://aicharged.io/api/v1/mcp'), {
requestInit: { headers: { Authorization: `Bearer ${process.env.AICHARGED_API_KEY}` } },
}));
const { tools } = await client.listTools();
console.log(tools.map((tool) => tool.name));
console.log(await client.callTool({ name: 'list_runs', arguments: {} }));