@@ -15,16 +15,19 @@ This directory contains examples demonstrating how to use the mcp-use library wi
1515## Running Examples
1616
1717First, build the library:
18+
1819``` bash
1920npm run build
2021```
2122
2223Then run any example using Node.js:
24+
2325``` bash
2426node dist/examples/example_name.js
2527```
2628
2729Or use the npm scripts:
30+
2831``` bash
2932npm run example:airbnb
3033npm run example:browser
@@ -35,32 +38,42 @@ npm run example:chat
3538## Available Examples
3639
3740### 1. Airbnb Search (` airbnb_use.ts ` )
41+
3842Search for accommodations using the Airbnb MCP server.
43+
3944``` bash
4045npm run example:airbnb
4146```
4247
4348### 2. Browser Automation (` browser_use.ts ` )
49+
4450Control a browser using Playwright MCP server.
51+
4552``` bash
4653npm run example:browser
4754```
4855
4956### 3. Interactive Chat (` chat_example.ts ` )
57+
5058Interactive chat session with conversation memory.
59+
5160``` bash
5261npm run example:chat
5362```
5463
5564### 4. File System Operations (` filesystem_use.ts ` )
65+
5666Access and manipulate files using the filesystem MCP server.
67+
5768``` bash
5869# First, edit the example to set your directory path
5970npm run example:filesystem
6071```
6172
6273### 5. HTTP Server Connection (` http_example.ts ` )
74+
6375Connect to an MCP server via HTTP.
76+
6477``` bash
6578# First, start the Playwright server in another terminal:
6679npx @playwright/mcp@latest --port 8931
@@ -70,33 +83,43 @@ npm run example:http
7083```
7184
7285### 6. MCP Everything Test (` mcp_everything.ts ` )
86+
7387Test various MCP functionalities.
88+
7489``` bash
7590npm run example:everything
7691```
7792
7893### 7. Multiple Servers (` multi_server_example.ts ` )
94+
7995Use multiple MCP servers in a single session.
96+
8097``` bash
8198# First, edit the example to set your directory path
8299npm run example:multi
83100```
84101
85102### 8. Sandboxed Environment (` sandbox_everything.ts ` )
103+
86104Run MCP servers in an E2B sandbox (requires E2B_API_KEY).
105+
87106``` bash
88107npm run example:sandbox
89108```
90109
91110### 9. OAuth Authentication (` simple_oauth_example.ts ` )
111+
92112OAuth flow example with Linear.
113+
93114``` bash
94115# First, register your app with Linear and update the client_id
95116npm run example:oauth
96117```
97118
98119### 10. Blender Integration (` blender_use.ts ` )
120+
99121Control Blender 3D through MCP.
122+
100123``` bash
101124# First, install and enable the Blender MCP addon
102125npm run example:blender
@@ -105,12 +128,14 @@ npm run example:blender
105128## Configuration Files
106129
107130Some examples use JSON configuration files:
131+
108132- ` airbnb_mcp.json ` - Airbnb server configuration
109133- ` browser_mcp.json ` - Browser server configuration
110134
111135## Environment Variables
112136
113137Different examples require different API keys:
138+
114139- ** ANTHROPIC_API_KEY** : For examples using Claude (airbnb, multi_server, blender)
115140- ** OPENAI_API_KEY** : For examples using GPT (browser, chat, filesystem, http, everything)
116141- ** E2B_API_KEY** : Only for the sandbox example
@@ -127,12 +152,14 @@ Different examples require different API keys:
127152To create a new example:
128153
1291541 . Import the necessary modules:
155+
130156 ``` typescript
131- import { MCPAgent , MCPClient } from ' ../index.js'
132157 import { ChatOpenAI } from ' @langchain/openai'
158+ import { MCPAgent , MCPClient } from ' ../index.js'
133159 ```
134160
1351612 . Configure your MCP server:
162+
136163 ``` typescript
137164 const config = {
138165 mcpServers: {
@@ -145,6 +172,7 @@ To create a new example:
145172 ```
146173
1471743 . Create client, LLM, and agent:
175+
148176 ``` typescript
149177 const client = MCPClient .fromDict (config )
150178 const llm = new ChatOpenAI ({ model: ' gpt-4o' })
@@ -159,7 +187,8 @@ To create a new example:
159187## Contributing
160188
161189Feel free to add more examples! Make sure to:
190+
1621911 . Follow the existing code style
1631922 . Add appropriate documentation
1641933 . Update this README with your example
165- 4 . Add a corresponding npm script in package.json
194+ 4 . Add a corresponding npm script in package.json
0 commit comments