Skip to content

LucaButBoring/simple-tasks-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-tasks-test

Simple test server for tasks

npm install
npm run start

Connect on http://localhost:3000/mcp

Client code:

const transport = new StreamableHTTPClientTransport(
  new URL("http://localhost:3000/mcp"),
);
await client.connect(transport);

const stream = client.experimental.tasks.callToolStream(
  { name: "slow-operation", arguments: { message: "Hello, world!" } },
  CallToolResultSchema,
  {
    task: { ttl: 60000 },
  },
);

for await (const message of stream) {
  switch (message.type) {
    case "taskCreated":
      console.log(`Task created: ${message.task.taskId}`);
      break;
    case "taskStatus":
      console.log(`Task status: ${message.task.status}`);
      break;
    case "result":
      console.log(`Result: ${getTextContent(message.result)}`);
      break;
    case "error":
      console.error(`Error: ${message.error}`);
      break;
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks