mcp-use 1.1.1-beta.0 → 1.1.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -65
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
<img src="https://dcbadge.limes.pink/api/server/XkNkSkMz3V?style=flat" /></a>
|
|
28
28
|
</p>
|
|
29
29
|
|
|
30
|
-
🌐 **
|
|
30
|
+
🌐 **mcp-use** is a complete TypeScript framework for building and using MCP (Model Context Protocol) applications. It provides both a powerful **client library** for connecting LLMs to MCP servers and a **server framework** for building your own MCP servers with UI capabilities.
|
|
31
31
|
|
|
32
32
|
💡 Build custom AI agents, create MCP servers with React UI widgets, and debug everything with the built-in inspector - all in TypeScript.
|
|
33
33
|
|
|
34
|
-
## 📦
|
|
34
|
+
## 📦 mcp-use Ecosystem
|
|
35
35
|
|
|
36
|
-
| Package
|
|
37
|
-
|
|
38
|
-
| **mcp-use**
|
|
39
|
-
| [@mcp-use/cli](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/cli)
|
|
40
|
-
| [@mcp-use/inspector](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/inspector)
|
|
41
|
-
| [create-mcp-use-app](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/create-mcp-use-app) | Create MCP apps with one command
|
|
36
|
+
| Package | Description | Version |
|
|
37
|
+
| ------------------------------------------------------------------------------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| **mcp-use** | Core framework for MCP clients and servers | [](https://www.npmjs.com/package/mcp-use) |
|
|
39
|
+
| [@mcp-use/cli](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/cli) | Build tool for MCP apps with UI widgets | [](https://www.npmjs.com/package/@mcp-use/cli) |
|
|
40
|
+
| [@mcp-use/inspector](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/inspector) | Web-based MCP server inspector and debugger | [](https://www.npmjs.com/package/@mcp-use/inspector) |
|
|
41
|
+
| [create-mcp-use-app](https://github.com/mcp-use/mcp-use-ts/tree/main/packages/create-mcp-use-app) | Create MCP apps with one command | [](https://www.npmjs.com/package/create-mcp-use-app) |
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
@@ -93,8 +93,8 @@ async function main() {
|
|
|
93
93
|
// 1. Configure MCP servers
|
|
94
94
|
const config = {
|
|
95
95
|
mcpServers: {
|
|
96
|
-
playwright: { command: 'npx', args: ['@playwright/mcp@latest'] }
|
|
97
|
-
}
|
|
96
|
+
playwright: { command: 'npx', args: ['@playwright/mcp@latest'] },
|
|
97
|
+
},
|
|
98
98
|
}
|
|
99
99
|
const client = MCPClient.fromDict(config)
|
|
100
100
|
|
|
@@ -105,7 +105,9 @@ async function main() {
|
|
|
105
105
|
const agent = new MCPAgent({ llm, client, maxSteps: 20 })
|
|
106
106
|
|
|
107
107
|
// 4. Run query
|
|
108
|
-
const result = await agent.run(
|
|
108
|
+
const result = await agent.run(
|
|
109
|
+
'Find the best restaurant in Tokyo using Google Search'
|
|
110
|
+
)
|
|
109
111
|
console.log('Result:', result)
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -187,13 +189,21 @@ npm install ai @langchain/anthropic
|
|
|
187
189
|
```ts
|
|
188
190
|
import { ChatAnthropic } from '@langchain/anthropic'
|
|
189
191
|
import { LangChainAdapter } from 'ai'
|
|
190
|
-
import {
|
|
192
|
+
import {
|
|
193
|
+
createReadableStreamFromGenerator,
|
|
194
|
+
MCPAgent,
|
|
195
|
+
MCPClient,
|
|
196
|
+
streamEventsToAISDK,
|
|
197
|
+
} from 'mcp-use'
|
|
191
198
|
|
|
192
199
|
async function createApiHandler() {
|
|
193
200
|
const config = {
|
|
194
201
|
mcpServers: {
|
|
195
|
-
everything: {
|
|
196
|
-
|
|
202
|
+
everything: {
|
|
203
|
+
command: 'npx',
|
|
204
|
+
args: ['-y', '@modelcontextprotocol/server-everything'],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
197
207
|
}
|
|
198
208
|
|
|
199
209
|
const client = new MCPClient(config)
|
|
@@ -218,8 +228,11 @@ import { streamEventsToAISDKWithTools } from 'mcp-use'
|
|
|
218
228
|
async function createEnhancedApiHandler() {
|
|
219
229
|
const config = {
|
|
220
230
|
mcpServers: {
|
|
221
|
-
everything: {
|
|
222
|
-
|
|
231
|
+
everything: {
|
|
232
|
+
command: 'npx',
|
|
233
|
+
args: ['-y', '@modelcontextprotocol/server-everything'],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
223
236
|
}
|
|
224
237
|
|
|
225
238
|
const client = new MCPClient(config)
|
|
@@ -243,15 +256,23 @@ async function createEnhancedApiHandler() {
|
|
|
243
256
|
// pages/api/chat.ts or app/api/chat/route.ts
|
|
244
257
|
import { ChatAnthropic } from '@langchain/anthropic'
|
|
245
258
|
import { LangChainAdapter } from 'ai'
|
|
246
|
-
import {
|
|
259
|
+
import {
|
|
260
|
+
createReadableStreamFromGenerator,
|
|
261
|
+
MCPAgent,
|
|
262
|
+
MCPClient,
|
|
263
|
+
streamEventsToAISDK,
|
|
264
|
+
} from 'mcp-use'
|
|
247
265
|
|
|
248
266
|
export async function POST(req: Request) {
|
|
249
267
|
const { prompt } = await req.json()
|
|
250
268
|
|
|
251
269
|
const config = {
|
|
252
270
|
mcpServers: {
|
|
253
|
-
everything: {
|
|
254
|
-
|
|
271
|
+
everything: {
|
|
272
|
+
command: 'npx',
|
|
273
|
+
args: ['-y', '@modelcontextprotocol/server-everything'],
|
|
274
|
+
},
|
|
275
|
+
},
|
|
255
276
|
}
|
|
256
277
|
|
|
257
278
|
const client = new MCPClient(config)
|
|
@@ -264,8 +285,7 @@ export async function POST(req: Request) {
|
|
|
264
285
|
const readableStream = createReadableStreamFromGenerator(aiSDKStream)
|
|
265
286
|
|
|
266
287
|
return LangChainAdapter.toDataStreamResponse(readableStream)
|
|
267
|
-
}
|
|
268
|
-
finally {
|
|
288
|
+
} finally {
|
|
269
289
|
await client.closeAllSessions()
|
|
270
290
|
}
|
|
271
291
|
}
|
|
@@ -327,7 +347,7 @@ LANGFUSE_HOST=https://cloud.langfuse.com # or your self-hosted instance
|
|
|
327
347
|
agent.setMetadata({
|
|
328
348
|
userId: 'user123',
|
|
329
349
|
sessionId: 'session456',
|
|
330
|
-
environment: 'production'
|
|
350
|
+
environment: 'production',
|
|
331
351
|
})
|
|
332
352
|
|
|
333
353
|
// Set tags for better organization
|
|
@@ -370,7 +390,7 @@ To disable observability, either remove langfuse env variables or
|
|
|
370
390
|
const agent = new MCPAgent({
|
|
371
391
|
llm,
|
|
372
392
|
client,
|
|
373
|
-
observe: false
|
|
393
|
+
observe: false,
|
|
374
394
|
})
|
|
375
395
|
```
|
|
376
396
|
|
|
@@ -444,8 +464,8 @@ See the [examples README](./examples/README.md) for detailed documentation and p
|
|
|
444
464
|
const config = {
|
|
445
465
|
mcpServers: {
|
|
446
466
|
airbnb: { command: 'npx', args: ['@openbnb/mcp-server-airbnb'] },
|
|
447
|
-
playwright: { command: 'npx', args: ['@playwright/mcp@latest'] }
|
|
448
|
-
}
|
|
467
|
+
playwright: { command: 'npx', args: ['@playwright/mcp@latest'] },
|
|
468
|
+
},
|
|
449
469
|
}
|
|
450
470
|
const client = MCPClient.fromDict(config)
|
|
451
471
|
const agent = new MCPAgent({ llm, client, useServerManager: true })
|
|
@@ -460,7 +480,7 @@ await agent.run('Search Airbnb in Barcelona, then Google restaurants nearby')
|
|
|
460
480
|
const agent = new MCPAgent({
|
|
461
481
|
llm,
|
|
462
482
|
client,
|
|
463
|
-
disallowedTools: ['file_system', 'network']
|
|
483
|
+
disallowedTools: ['file_system', 'network'],
|
|
464
484
|
})
|
|
465
485
|
```
|
|
466
486
|
|
|
@@ -478,19 +498,19 @@ import { createMCPServer } from 'mcp-use/server'
|
|
|
478
498
|
// Create your MCP server
|
|
479
499
|
const server = createMCPServer('my-awesome-server', {
|
|
480
500
|
version: '1.0.0',
|
|
481
|
-
description: 'My MCP server with tools, resources, and prompts'
|
|
501
|
+
description: 'My MCP server with tools, resources, and prompts',
|
|
482
502
|
})
|
|
483
503
|
|
|
484
504
|
// Define tools
|
|
485
505
|
server.tool('search_web', {
|
|
486
506
|
description: 'Search the web for information',
|
|
487
507
|
parameters: z.object({
|
|
488
|
-
query: z.string().describe('Search query')
|
|
508
|
+
query: z.string().describe('Search query'),
|
|
489
509
|
}),
|
|
490
510
|
execute: async (args) => {
|
|
491
511
|
// Your tool implementation
|
|
492
512
|
return { results: await performSearch(args.query) }
|
|
493
|
-
}
|
|
513
|
+
},
|
|
494
514
|
})
|
|
495
515
|
|
|
496
516
|
// Define resources
|
|
@@ -500,18 +520,16 @@ server.resource('config', {
|
|
|
500
520
|
mimeType: 'application/json',
|
|
501
521
|
fetch: async () => {
|
|
502
522
|
return JSON.stringify(await getConfig(), null, 2)
|
|
503
|
-
}
|
|
523
|
+
},
|
|
504
524
|
})
|
|
505
525
|
|
|
506
526
|
// Define prompts
|
|
507
527
|
server.prompt('code_review', {
|
|
508
528
|
description: 'Review code for best practices',
|
|
509
|
-
arguments: [
|
|
510
|
-
{ name: 'code', description: 'Code to review', required: true }
|
|
511
|
-
],
|
|
529
|
+
arguments: [{ name: 'code', description: 'Code to review', required: true }],
|
|
512
530
|
render: async (args) => {
|
|
513
531
|
return `Please review this code:\n\n${args.code}`
|
|
514
|
-
}
|
|
532
|
+
},
|
|
515
533
|
})
|
|
516
534
|
|
|
517
535
|
// Start the server
|
|
@@ -522,19 +540,19 @@ server.listen(3000)
|
|
|
522
540
|
|
|
523
541
|
### Key Server Features
|
|
524
542
|
|
|
525
|
-
| Feature
|
|
526
|
-
|
|
527
|
-
| **🔍 Auto Inspector**
|
|
528
|
-
| **🎨 UI Widgets**
|
|
529
|
-
| **🔐 OAuth Support**
|
|
530
|
-
| **📡 Multiple Transports** | HTTP/SSE and WebSocket support out of the box
|
|
531
|
-
| **🛠️ TypeScript First**
|
|
532
|
-
| **♻️ Hot Reload**
|
|
533
|
-
| **📊 Observability**
|
|
543
|
+
| Feature | Description |
|
|
544
|
+
| -------------------------- | ---------------------------------------------------------------- |
|
|
545
|
+
| **🔍 Auto Inspector** | Inspector UI automatically mounts at `/inspector` for debugging |
|
|
546
|
+
| **🎨 UI Widgets** | Build custom React UI components served alongside your MCP tools |
|
|
547
|
+
| **🔐 OAuth Support** | Built-in OAuth flow handling for secure authentication |
|
|
548
|
+
| **📡 Multiple Transports** | HTTP/SSE and WebSocket support out of the box |
|
|
549
|
+
| **🛠️ TypeScript First** | Full TypeScript support with type inference |
|
|
550
|
+
| **♻️ Hot Reload** | Development mode with automatic reloading |
|
|
551
|
+
| **📊 Observability** | Built-in logging and monitoring capabilities |
|
|
534
552
|
|
|
535
553
|
### MCP-UI Resources
|
|
536
554
|
|
|
537
|
-
|
|
555
|
+
mcp-use provides a unified `uiResource()` method for registering interactive UI widgets that are compatible with MCP-UI clients. This automatically creates both a tool (for dynamic parameters) and a resource (for static access).
|
|
538
556
|
|
|
539
557
|
#### Quick Start
|
|
540
558
|
|
|
@@ -551,23 +569,24 @@ server.uiResource({
|
|
|
551
569
|
title: 'Kanban Board',
|
|
552
570
|
description: 'Interactive task management board',
|
|
553
571
|
props: {
|
|
554
|
-
initialTasks: {
|
|
555
|
-
type: 'array',
|
|
572
|
+
initialTasks: {
|
|
573
|
+
type: 'array',
|
|
556
574
|
description: 'Initial tasks',
|
|
557
|
-
required: false
|
|
575
|
+
required: false,
|
|
576
|
+
},
|
|
577
|
+
theme: {
|
|
578
|
+
type: 'string',
|
|
579
|
+
default: 'light',
|
|
558
580
|
},
|
|
559
|
-
theme: {
|
|
560
|
-
type: 'string',
|
|
561
|
-
default: 'light'
|
|
562
|
-
}
|
|
563
581
|
},
|
|
564
|
-
size: ['900px', '600px']
|
|
582
|
+
size: ['900px', '600px'],
|
|
565
583
|
})
|
|
566
584
|
|
|
567
585
|
server.listen(3000)
|
|
568
586
|
```
|
|
569
587
|
|
|
570
588
|
This automatically creates:
|
|
589
|
+
|
|
571
590
|
- **Tool**: `ui_kanban-board` - Accepts parameters and returns UIResource
|
|
572
591
|
- **Resource**: `ui://widget/kanban-board` - Static access with defaults
|
|
573
592
|
|
|
@@ -581,7 +600,7 @@ server.uiResource({
|
|
|
581
600
|
type: 'externalUrl',
|
|
582
601
|
name: 'dashboard',
|
|
583
602
|
widget: 'dashboard',
|
|
584
|
-
props: { userId: { type: 'string', required: true } }
|
|
603
|
+
props: { userId: { type: 'string', required: true } },
|
|
585
604
|
})
|
|
586
605
|
```
|
|
587
606
|
|
|
@@ -597,7 +616,7 @@ server.uiResource({
|
|
|
597
616
|
<html>
|
|
598
617
|
<body><h1>Welcome!</h1></body>
|
|
599
618
|
</html>
|
|
600
|
-
|
|
619
|
+
`,
|
|
601
620
|
})
|
|
602
621
|
```
|
|
603
622
|
|
|
@@ -613,7 +632,7 @@ server.uiResource({
|
|
|
613
632
|
button.setAttribute('label', 'Vote');
|
|
614
633
|
root.appendChild(button);
|
|
615
634
|
`,
|
|
616
|
-
framework: 'react'
|
|
635
|
+
framework: 'react',
|
|
617
636
|
})
|
|
618
637
|
```
|
|
619
638
|
|
|
@@ -631,7 +650,7 @@ npm run dev
|
|
|
631
650
|
|
|
632
651
|
### Building Custom UI Widgets
|
|
633
652
|
|
|
634
|
-
|
|
653
|
+
mcp-use supports building custom UI widgets for your MCP tools using React:
|
|
635
654
|
|
|
636
655
|
```tsx
|
|
637
656
|
// resources/task-manager.tsx
|
|
@@ -656,7 +675,7 @@ export default function TaskManager() {
|
|
|
656
675
|
}
|
|
657
676
|
```
|
|
658
677
|
|
|
659
|
-
Build and serve widgets using the
|
|
678
|
+
Build and serve widgets using the mcp-use CLI:
|
|
660
679
|
|
|
661
680
|
```bash
|
|
662
681
|
# Development with hot reload and auto-open inspector
|
|
@@ -682,7 +701,7 @@ const server = createMCPServer('advanced-server', {
|
|
|
682
701
|
// Enable CORS for browser access
|
|
683
702
|
cors: {
|
|
684
703
|
origin: ['http://localhost:3000', 'https://myapp.com'],
|
|
685
|
-
credentials: true
|
|
704
|
+
credentials: true,
|
|
686
705
|
},
|
|
687
706
|
// OAuth configuration
|
|
688
707
|
oauth: {
|
|
@@ -690,13 +709,10 @@ const server = createMCPServer('advanced-server', {
|
|
|
690
709
|
clientSecret: process.env.OAUTH_CLIENT_SECRET,
|
|
691
710
|
authorizationUrl: 'https://api.example.com/oauth/authorize',
|
|
692
711
|
tokenUrl: 'https://api.example.com/oauth/token',
|
|
693
|
-
scopes: ['read', 'write']
|
|
712
|
+
scopes: ['read', 'write'],
|
|
694
713
|
},
|
|
695
714
|
// Custom middleware
|
|
696
|
-
middleware: [
|
|
697
|
-
authenticationMiddleware,
|
|
698
|
-
rateLimitingMiddleware
|
|
699
|
-
]
|
|
715
|
+
middleware: [authenticationMiddleware, rateLimitingMiddleware],
|
|
700
716
|
})
|
|
701
717
|
```
|
|
702
718
|
|
|
@@ -730,9 +746,11 @@ const app = express()
|
|
|
730
746
|
app.get('/api/health', (req, res) => res.send('OK'))
|
|
731
747
|
|
|
732
748
|
// Mount MCP server
|
|
733
|
-
const mcpServer = createMCPServer('integrated-server', {
|
|
749
|
+
const mcpServer = createMCPServer('integrated-server', {
|
|
750
|
+
/* ... */
|
|
751
|
+
})
|
|
734
752
|
mountMCPServer(app, mcpServer, {
|
|
735
|
-
basePath: '/mcp-service'
|
|
753
|
+
basePath: '/mcp-service', // Optional custom base path
|
|
736
754
|
})
|
|
737
755
|
|
|
738
756
|
app.listen(3000)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-use",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.1-
|
|
4
|
+
"version": "1.1.1-canary.0",
|
|
5
5
|
"description": "Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents and Clients + MCP Servers with support for MCP-UI.",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@mcp-use/inspector": "^0.4.1-
|
|
59
|
+
"@mcp-use/inspector": "^0.4.1-canary.0",
|
|
60
60
|
"cors": "^2.8.5",
|
|
61
61
|
"express": "^4.18.2",
|
|
62
62
|
"langfuse": "^3.32.0",
|