@mcp-use/agent 2.0.0-beta.16 → 2.0.0-beta.18
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 +145 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/agents/display.d.ts.map +1 -1
- package/dist/agents/mcp_agent.d.ts.map +1 -1
- package/dist/agents/mcp_agent_langchain.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/langchain.d.ts +3 -0
- package/dist/langchain.d.ts.map +1 -1
- package/dist/langchain.js +178 -42743
- package/dist/langchain.js.map +1 -1
- package/package.json +7 -11
- package/dist/browser-agent.d.ts +0 -9
- package/dist/browser-agent.d.ts.map +0 -1
- package/dist/browser-agent.js +0 -3318
- package/dist/browser-agent.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<div align="center" style="margin: 0 auto; max-width: 80%;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use/main/static/logo_white.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/mcp-use/mcp-use/main/static/logo_black.svg">
|
|
5
|
+
<img alt="mcp use logo" src="https://raw.githubusercontent.com/mcp-use/mcp-use/main/static/logo_white.svg" width="80%" style="margin: 20px auto;">
|
|
6
|
+
</picture>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">@mcp-use/agent</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@mcp-use/agent" alt="NPM Downloads">
|
|
13
|
+
<img src="https://img.shields.io/npm/dw/@mcp-use/agent.svg"/></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@mcp-use/agent" alt="NPM Version">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/@mcp-use/agent.svg"/></a>
|
|
16
|
+
<a href="https://github.com/mcp-use/mcp-use/blob/main/LICENSE" alt="License">
|
|
17
|
+
<img src="https://img.shields.io/github/license/mcp-use/mcp-use" /></a>
|
|
18
|
+
<a href="https://discord.gg/XkNkSkMz3V" alt="Discord">
|
|
19
|
+
<img src="https://dcbadge.limes.pink/api/server/XkNkSkMz3V?style=flat" /></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
**Native cross-platform MCP agent** — connect an LLM to MCP servers, run a tool-calling loop, stream steps, and return answers. Works in **Node and browser** from the same import. Part of the [mcp-use](https://github.com/mcp-use/mcp-use) TypeScript framework.
|
|
23
|
+
|
|
24
|
+
> **Docs:** [Agent overview](https://mcp-use.com/docs/typescript/agent) · [API reference](https://mcp-use.com/docs/typescript/api-reference/agent/mcp-agent)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @mcp-use/agent
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Requires Node.js ≥ 22.22.2. `@mcp-use/client` is included as a dependency.
|
|
35
|
+
|
|
36
|
+
For the LangChain bridge (`import { MCPAgent } from "@mcp-use/agent/langchain"`), also install the peers you use, for example:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install langchain @langchain/openai
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { MCPAgent } from "@mcp-use/agent";
|
|
48
|
+
|
|
49
|
+
const agent = new MCPAgent({
|
|
50
|
+
llm: "openai/gpt-4o",
|
|
51
|
+
mcpServers: {
|
|
52
|
+
filesystem: {
|
|
53
|
+
command: "npx",
|
|
54
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "./"],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const result = await agent.run({ prompt: "What is in the current folder?" });
|
|
60
|
+
console.log(result);
|
|
61
|
+
|
|
62
|
+
await agent.close();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`run({ prompt })` returns the final answer. Raise `maxSteps` for multi-tool tasks. Always call `close()` when the agent owns its client.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## LangChain bridge
|
|
70
|
+
|
|
71
|
+
Use the same `MCPAgent` class name from a separate entry when you need LangChain models, Langfuse tracing, Server Manager, or AI SDK streaming:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
75
|
+
import { MCPAgent } from "@mcp-use/agent/langchain";
|
|
76
|
+
import { MCPClient } from "@mcp-use/client";
|
|
77
|
+
|
|
78
|
+
const mcpServers = {
|
|
79
|
+
filesystem: {
|
|
80
|
+
command: "npx",
|
|
81
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "./"],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const client = new MCPClient({ mcpServers });
|
|
86
|
+
const agent = new MCPAgent({
|
|
87
|
+
llm: new ChatOpenAI({ model: "gpt-4o" }),
|
|
88
|
+
client,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const result = await agent.run({ prompt: "Summarize the repo README" });
|
|
92
|
+
await agent.close();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Features
|
|
98
|
+
|
|
99
|
+
| Feature | Entry | Description |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| **Tool-calling loop** | `@mcp-use/agent` | LLM discovers and calls MCP tools until it can answer |
|
|
102
|
+
| **Simplified setup** | `@mcp-use/agent` | `"provider/model"` + `mcpServers` — no manual client/LLM wiring |
|
|
103
|
+
| **Streaming** | `@mcp-use/agent` | `stream()` for steps, `streamEvents()` for native LLM events |
|
|
104
|
+
| **Structured output** | `@mcp-use/agent/langchain` | Zod `schema` on `run({ prompt, schema })` |
|
|
105
|
+
| **Memory** | both | Conversation history across `run()` calls |
|
|
106
|
+
| **Server Manager** | `@mcp-use/agent/langchain` | Dynamically add MCP servers during a run |
|
|
107
|
+
| **Observability** | `@mcp-use/agent/langchain` | Langfuse metadata, tags, and trace flush |
|
|
108
|
+
| **Remote agent** | `@mcp-use/agent` | Run against Manufact Cloud by `agentId` |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Package entry points
|
|
113
|
+
|
|
114
|
+
| Import | Environment | Description |
|
|
115
|
+
| --- | --- | --- |
|
|
116
|
+
| `@mcp-use/agent` | Node + browser | Native `MCPAgent` (fetch-based LLM drivers) |
|
|
117
|
+
| `@mcp-use/agent/langchain` | Node | LangChain `MCPAgent` (optional peer deps) |
|
|
118
|
+
|
|
119
|
+
In the browser, pass HTTP MCP URLs or live connections from `@mcp-use/client/react`. Stdio `command`/`args` server configs are Node-only.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Examples
|
|
124
|
+
|
|
125
|
+
See [examples/README.md](./examples/README.md). Run from this package:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
OPENAI_API_KEY=... pnpm exec tsx examples/basic/simplified_agent_example.ts
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Related packages
|
|
134
|
+
|
|
135
|
+
| Package | Description |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| [@mcp-use/client](https://www.npmjs.com/package/@mcp-use/client) | MCP client (HTTP, stdio, React hooks) |
|
|
138
|
+
| [mcp-use](https://www.npmjs.com/package/mcp-use) | Full framework (server + agent + client) |
|
|
139
|
+
| [@mcp-use/inspector](https://www.npmjs.com/package/@mcp-use/inspector) | Web-based MCP debugger |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT
|