feat(transport): support streamable http server (#152)
* feat(transport): support streamable http server * refactor(transport): add common module for shared transport utilities * perf(tracing): add more log for streamable http session * fix(test): fix port conflict in test with js * fix(transport): fix id generating and session management 1. cancel when deleting 2. use `wrapping` and `saturating` correctly * chore(naming): rename sse server to streamable http server
This commit is contained in:
parent
0847c17fa1
commit
57e14c56e8
1 changed files with 1247 additions and 20 deletions
28
crates/rmcp/tests/test_with_js/streamable_client.js
Normal file
28
crates/rmcp/tests/test_with_js/streamable_client.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||
|
||||
const transport = new StreamableHTTPClientTransport(new URL(`http://127.0.0.1:8001/`));
|
||||
|
||||
const client = new Client(
|
||||
{
|
||||
name: "example-client",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
prompts: {},
|
||||
resources: {},
|
||||
tools: {}
|
||||
}
|
||||
}
|
||||
);
|
||||
await client.connect(transport);
|
||||
const tools = await client.listTools();
|
||||
console.log(tools);
|
||||
const resources = await client.listResources();
|
||||
console.log(resources);
|
||||
const templates = await client.listResourceTemplates();
|
||||
console.log(templates);
|
||||
const prompts = await client.listPrompts();
|
||||
console.log(prompts);
|
||||
await client.close();
|
||||
Loading…
Reference in a new issue