TypeScript (MCP SDK)
공식 TypeScript MCP SDK(2.3.0 이상)와 StreamableHTTPClientTransport.
- API 키(Bearer)
패키지 설치
npm install @modelcontextprotocol/client@^2.3.0
2.3.0 이상을 사용하세요(리다이렉트 시 headers가 다시 전송되는 문제의 보안 수정).
클라이언트 코드
추천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: {} }));