Skip to main content

TypeScript (MCP SDK) を aicharged.io に接続

215個のツール、1つのエンドポイント: https://aicharged.io/api/v1/mcp

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

またはCLIで自動設定する

aicharged setupは、このマシン上のAIクライアントを検出し、ブラウザ経由でサインインして、その設定を書き込みます。

1行で接続

CLIのインストール · macOS / Linux
curl -fsSL https://aicharged.io/install.sh | sh && aicharged setup
CLIのインストール · Windows
irm https://aicharged.io/install.ps1 | iex; aicharged setup
MCPエンドポイント
https://aicharged.io/api/v1/mcp

ストリーミング可能なHTTP。ヘッダー Authorization: Bearer <API_KEY> を送信するか、クライアントが対応している場合はOAuthでサインインしてください。

またはエージェントに指示する
https://aicharged.io/agent.md を読んで、aicharged.io をセットアップしてください

このプロンプトで開く: Claude (新しいタブで開きます) ChatGPT (新しいタブで開きます) Perplexity (新しいタブで開きます)