Skip to content

Conversation

@vippelina
Copy link

@vippelina vippelina commented Dec 29, 2025

Add TypeScript multi-server chatbot example

Implements a TypeScript chatbot example that connects to multiple MCP servers with LLM integration, following the pattern from the Python SDK's simple-chatbot.

Motivation and Context

Closes #740

The TypeScript SDK needed an example showing how to build a chatbot that connects to multiple MCP servers and integrates with an LLM. This example demonstrates:

  • Multi-server connection using StdioClientTransport
  • Dynamic tool discovery from all connected servers
  • LLM integration (OpenAI-compatible APIs)
  • Tool execution with natural language responses
  • Conversation state management

How Has This Been Tested?

Automated tests:

  • Created integration test suite in simpleChatbot.test.ts (14 tests)
  • All tests pass, including regression test for JSON output leaks

Manual testing:

  • Direct responses without tools
  • Single and multi-parameter tool calls
  • Handling requests for non-existent tools
  • Multi-turn conversations with context
  • Exit methods (quit, exit, Ctrl+C)
  • Verified no raw JSON appears in user output

Tested with @modelcontextprotocol/server-everything and @modelcontextprotocol/server-memory using Groq's llama-3.3-70b-versatile.

Breaking Changes

None - this is a new example.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This PR represents my first contribution while learning to work with MCP connections. @felixweinberger Thanks for providing the list with good first issues! Really educational for me to work with this. Will continue improving the example here. Happy to further contribute.

@vippelina vippelina requested a review from a team as a code owner December 29, 2025 20:24
@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

⚠️ No Changeset found

Latest commit: a18ac96

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 29, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1348
npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1348

commit: a18ac96

- Remove JSON config files with absolute local paths
- Generate test configs dynamically using __dirname
- Handle expected connection closed errors in cleanup test
- All 13 tests passing locally and should pass in CI
import { createServer, type Server } from 'node:http';

import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
import type { EventStore, JSONRPCMessage } from '@modelcontextprotocol/server';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result of lint:fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can we have a chatbot example that connected to multiple remote servers

2 participants