24 lines
786 B
JavaScript
24 lines
786 B
JavaScript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
|
|
async function run() {
|
|
console.log("Connecting with StreamableHTTPClientTransport...");
|
|
const transport = new StreamableHTTPClientTransport(new URL("http://localhost:3002/mcp"), {
|
|
requestInit: {
|
|
headers: {
|
|
"Authorization": "Bearer MyToKeN"
|
|
}
|
|
}
|
|
});
|
|
|
|
const client = new Client({ name: "test", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
|
|
await client.connect(transport);
|
|
console.log("Connected! Fetching tools...");
|
|
const { tools } = await client.listTools();
|
|
console.log("Tools found:", tools.map(t => t.name));
|
|
process.exit(0);
|
|
}
|
|
|
|
run().catch(console.error);
|