import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
const transport = new StdioClientTransport({
command: "node",
args: ["build/index.js"],
});
const client = new Client(
{
name: "test-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
await client.connect(transport);
console.log("=== ツール一覧の取得 ===");
const tools = await client.listTools();
console.log(JSON.stringify(tools, null, 2));
console.log("\n=== 法人番号検索のテスト (要APIキー) ===");
try {
// 注: APIキーが設定されていないとエラーになります
const result = await client.callTool({
name: "list_corporation",
arguments: {
corporate_number: "5010001008823", // サンプル: トヨタ自動車
},
});
console.log(JSON.stringify(result, null, 2));
} catch (e) {
console.log("法人番号APIのエラー (想定内: キー未設定):", (e as Error).message);
}
// 法令APIはキー不要で動くはずです
console.log("\n=== 法令検索のテスト (法人税法 34条) ===");
try {
const result = await client.callTool({
name: "get_law_article",
arguments: {
law_name: "法人税法",
article: "第三十四条",
paragraph: "1",
},
});
console.log(JSON.stringify(result, null, 2));
} catch (e) {
console.log("法令APIのエラー:", (e as Error).message);
}
console.log("\n=== 地域統計のテスト (要APIキー) ===");
try {
const result = await client.callTool({
name: "get_region_stats",
arguments: {
prefecture: "石川県",
sector_code: "E",
},
});
console.log(JSON.stringify(result, null, 2));
} catch (e) {
console.log("地域統計APIのエラー (想定内: キー未設定):", (e as Error).message);
}
await client.close();
}
main().catch(console.error);