Initial commit: Add NanoClaw MCP extension with README and secure tests
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
||||
import * as EventSource from "eventsource";
|
||||
|
||||
global.EventSource = EventSource;
|
||||
|
||||
async function run() {
|
||||
console.log("Connecting...");
|
||||
const transport = new SSEClientTransport(new URL("http://localhost:3002/mcp"), {
|
||||
requestInit: {
|
||||
headers: {
|
||||
"Authorization": "Bearer MyToKeN"
|
||||
}
|
||||
},
|
||||
eventSourceInit: {
|
||||
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);
|
||||
Reference in New Issue
Block a user