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: {} }));