Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d0cbc4
fix: barebone with structure
vippelinalf Dec 28, 2025
6f77aa1
added some test fixtures
vippelinalf Dec 28, 2025
01ac657
added load config tesr
vippelinalf Dec 28, 2025
b18ebe4
feat: connectToServer fn added
vippelinalf Dec 28, 2025
ffe424c
feat: connectToAllServers
vippelinalf Dec 28, 2025
ae9adc3
feat: chatsession constructor and properties
vippelinalf Dec 28, 2025
7820f35
feat: ChatSession - getAvailableTools fn
vippelinalf Dec 28, 2025
baf0242
feat: process LLM response added
vippelinalf Dec 28, 2025
94c56ec
fix: fixed flaky tests
vippelinalf Dec 28, 2025
686a066
i might need absolute paths here?
vippelinalf Dec 28, 2025
b9a9933
feat: implemented close functionality
vippelinalf Dec 28, 2025
bece3c0
feat: added final chat loop with corresponding tests
vippelinalf Dec 28, 2025
f69c4de
Updated readme with chatbot example
vippelinalf Dec 29, 2025
2b1a716
lint fixing
vippelinalf Dec 29, 2025
5764b84
feat:
vippelinalf Dec 29, 2025
a5e06b4
fix:
vippelinalf Dec 29, 2025
902bb8f
fix: remove hardcoded paths from test fixtures for CI compatibility
vippelinalf Dec 29, 2025
ec44767
fix: use real servers for the test
vippelinalf Dec 29, 2025
743f6e5
fix: misc fixes
vippelinalf Dec 29, 2025
3957c8b
refactor: moved chatbot test to integration test. Improved performanc…
vippelinalf Dec 29, 2025
a6eb251
non related: lint fixes only
vippelinalf Dec 29, 2025
f35104b
lockfile!
vippelinalf Dec 29, 2025
daba177
format issue fix
vippelinalf Dec 29, 2025
6fb4011
no need to run tests in client foldercsince moved to integration
vippelinalf Dec 29, 2025
7b5f0fa
maaaaaaa
vippelinalf Dec 29, 2025
b1283de
readded config file (it was there before)
vippelinalf Dec 29, 2025
a18ac96
removed unused servers_config
vippelinalf Dec 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# LLM API Key
# Get your API key from your LLM provider (OpenAI, Groq, etc.)
LLM_API_KEY=your_api_key_here
36 changes: 36 additions & 0 deletions examples/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Most clients expect a server to be running. Start one from [`../server/README.md

| Scenario | Description | File |
| --------------------------------------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Simple multi-server chatbot | CLI chatbot connecting to multiple MCP servers via STDIO with LLM integration. | [`src/simpleChatbot.ts`](src/simpleChatbot.ts) |
| Interactive Streamable HTTP client | CLI client that exercises tools/resources/prompts, notifications, elicitation, and tasks. | [`src/simpleStreamableHttp.ts`](src/simpleStreamableHttp.ts) |
| Backwards-compatible client (Streamable HTTP → SSE) | Tries Streamable HTTP first, falls back to legacy SSE on 4xx responses. | [`src/streamableHttpWithSseFallbackClient.ts`](src/streamableHttpWithSseFallbackClient.ts) |
| SSE polling client (legacy) | Polls a legacy HTTP+SSE server and demonstrates notification handling. | [`src/ssePollingClient.ts`](src/ssePollingClient.ts) |
Expand All @@ -37,6 +38,41 @@ Most clients expect a server to be running. Start one from [`../server/README.md
| URL elicitation client | Drives URL-mode elicitation flows (sensitive input in a browser). | [`src/elicitationUrlExample.ts`](src/elicitationUrlExample.ts) |
| Task interactive client | Demonstrates task-based execution + interactive server→client requests. | [`src/simpleTaskInteractiveClient.ts`](src/simpleTaskInteractiveClient.ts) |

## Simple chatbot example

The simple chatbot demonstrates connecting to multiple MCP servers simultaneously and integrating with an LLM provider.

**Configuration:**

A `servers_config.json` file is included with default server configurations. You can edit it to add or modify servers:

```json
{
"mcpServers": {
"everything": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"]
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
}
```

The chatbot will discover tools from all configured servers and allow interactive conversation. Type `quit` or `exit` to end the session.

**Running:**

```bash
# Set your LLM API key (OpenAI, Groq, etc.)
export LLM_API_KEY=your_api_key_here

# Run the chatbot
pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleChatbot.ts
```

## URL elicitation example (server + client)

Run the server first:
Expand Down
3 changes: 2 additions & 1 deletion examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@modelcontextprotocol/tsconfig": "workspace:^",
"@modelcontextprotocol/eslint-config": "workspace:^",
"@modelcontextprotocol/vitest-config": "workspace:^",
"tsdown": "catalog:devTools"
"tsdown": "catalog:devTools",
"vitest": "catalog:devTools"
}
}
8 changes: 8 additions & 0 deletions examples/client/servers_config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"]
}
}
}
12 changes: 12 additions & 0 deletions examples/client/servers_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mcpServers": {
"everything": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-everything"]
},
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
}
Loading
Loading