@h1deya/langchain-mcp-tools 0.4.1 → 0.4.2
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 +52 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,10 @@ You might want to consider using it if the extra features that this library supp
|
|
|
19
19
|
## Prerequisites
|
|
20
20
|
|
|
21
21
|
- Node.js 18+
|
|
22
|
+
- [optional] [npm 7+ (`npx`)](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
|
23
|
+
to run Node.js package-based local MCP servers
|
|
24
|
+
- [optional] [`uv` (`uvx`)](https://docs.astral.sh/uv/getting-started/installation/)
|
|
25
|
+
installed to run Python-based local (stdio) MCP servers
|
|
22
26
|
|
|
23
27
|
## Installation
|
|
24
28
|
|
|
@@ -47,7 +51,7 @@ const mcpServers: McpServersConfig = {
|
|
|
47
51
|
"brave-search": {
|
|
48
52
|
command: "npx",
|
|
49
53
|
args: [ "-y", "@modelcontextprotocol/server-brave-search"],
|
|
50
|
-
env: { "BRAVE_API_KEY":
|
|
54
|
+
env: { "BRAVE_API_KEY": process.env.BRAVE_API_KEY || "" }
|
|
51
55
|
},
|
|
52
56
|
github: {
|
|
53
57
|
type: "http",
|
|
@@ -120,7 +124,7 @@ try {
|
|
|
120
124
|
}
|
|
121
125
|
```
|
|
122
126
|
|
|
123
|
-
A
|
|
127
|
+
**A simple working usage example** can be found
|
|
124
128
|
[in this example in the langchain-mcp-tools-ts-usage repo](https://github.com/hideya/langchain-mcp-tools-ts-usage/blob/main/src/index.ts)
|
|
125
129
|
|
|
126
130
|
For hands-on experimentation with MCP server integration,
|
|
@@ -129,6 +133,25 @@ try [this MCP Client CLI tool built with this library](https://www.npmjs.com/pac
|
|
|
129
133
|
A Python equivalent of this utility is available
|
|
130
134
|
[here](https://pypi.org/project/langchain-mcp-tools)
|
|
131
135
|
|
|
136
|
+
|
|
137
|
+
## API Reference
|
|
138
|
+
|
|
139
|
+
Can be found [here](https://hideya.github.io/langchain-mcp-tools-ts/modules.html)
|
|
140
|
+
|
|
141
|
+
## Change Log
|
|
142
|
+
|
|
143
|
+
Can be found [here](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/CHANGELOG.md)
|
|
144
|
+
|
|
145
|
+
## Working Usage Example
|
|
146
|
+
Can be found
|
|
147
|
+
[in this example in the langchain-mcp-tools-ts-usage repo](https://github.com/hideya/langchain-mcp-tools-ts-usage/blob/main/src/index.ts)
|
|
148
|
+
|
|
149
|
+
## Building from Source
|
|
150
|
+
|
|
151
|
+
See [README_DEV.md](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README_DEV.md) for details.
|
|
152
|
+
|
|
153
|
+
<br/>
|
|
154
|
+
|
|
132
155
|
## Introduction
|
|
133
156
|
|
|
134
157
|
This package is intended to simplify the use of
|
|
@@ -167,7 +190,7 @@ While MCP tools can return multiple content types (text, images, etc.), this lib
|
|
|
167
190
|
|
|
168
191
|
- **LLM Compatibility and Schema Transformations**: The library can perform schema transformations for LLM compatibility.
|
|
169
192
|
[See below](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README.md#llm-provider-schema-compatibility) for details.
|
|
170
|
-
- **Passing PATH Env Variable**: The library automatically adds the `PATH` environment variable to local
|
|
193
|
+
- **Passing PATH Env Variable**: The library automatically adds the `PATH` environment variable to local server configrations if not explicitly provided to ensure servers can find required executables.
|
|
171
194
|
|
|
172
195
|
## Features
|
|
173
196
|
|
|
@@ -180,18 +203,15 @@ via environment variables, use this example as a guide:
|
|
|
180
203
|
brave: {
|
|
181
204
|
command: "npx",
|
|
182
205
|
args: [ "-y", "@modelcontextprotocol/server-brave-search"],
|
|
183
|
-
env: { "BRAVE_API_KEY":
|
|
206
|
+
env: { "BRAVE_API_KEY": process.env.BRAVE_API_KEY || "" }
|
|
184
207
|
},
|
|
185
208
|
```
|
|
186
209
|
|
|
187
|
-
**Note**: The library automatically adds the `PATH` environment variable to local
|
|
210
|
+
**Note**: The library automatically adds the `PATH` environment variable to local server configrations, if not explicitly provided, to ensure servers can find required executables.
|
|
188
211
|
|
|
189
212
|
### `stderr` Redirection for Local MCP Server
|
|
190
213
|
|
|
191
|
-
A new key `"stderr"` has been introduced to specify a file descriptor
|
|
192
|
-
to which local (stdio) MCP server's stderr is redirected.
|
|
193
|
-
The key name `stderr` is derived from
|
|
194
|
-
TypeScript SDK's [`StdioServerParameters`](https://github.com/modelcontextprotocol/typescript-sdk/blob/131776764536b5fdca642df51230a3746fb4ade0/src/client/stdio.ts#L32).
|
|
214
|
+
A new key `"stderr"` has been introduced to specify a file descriptor to which local MCP server's stderr is redirected.
|
|
195
215
|
|
|
196
216
|
```ts
|
|
197
217
|
const logPath = `mcp-server-${serverName}.log`;
|
|
@@ -200,11 +220,14 @@ TypeScript SDK's [`StdioServerParameters`](https://github.com/modelcontextprotoc
|
|
|
200
220
|
```
|
|
201
221
|
|
|
202
222
|
A usage example can be found [here](
|
|
203
|
-
https://github.com/hideya/langchain-mcp-tools-ts-usage/blob/
|
|
223
|
+
https://github.com/hideya/langchain-mcp-tools-ts-usage/blob/8d36e901e55e60d8a1e1af40e2d5c8dc36a6d069/src/index.ts#L90-L101
|
|
224
|
+
).
|
|
225
|
+
The key name `stderr` is derived from
|
|
226
|
+
TypeScript SDK's [`StdioServerParameters`](https://github.com/modelcontextprotocol/typescript-sdk/blob/131776764536b5fdca642df51230a3746fb4ade0/src/client/stdio.ts#L32).
|
|
204
227
|
|
|
205
228
|
### Working Directory Configuration for Local MCP Servers
|
|
206
229
|
|
|
207
|
-
The working directory that is used when spawning a local
|
|
230
|
+
The working directory that is used when spawning a local MCP server
|
|
208
231
|
can be specified with the `"cwd"` key as follows:
|
|
209
232
|
|
|
210
233
|
```ts
|
|
@@ -224,10 +247,11 @@ The library selects transports using the following priority order:
|
|
|
224
247
|
|
|
225
248
|
1. **Explicit transport/type field** (must match URL protocol if URL provided)
|
|
226
249
|
2. **URL protocol auto-detection** (http/https → StreamableHTTP → SSE, ws/wss → WebSocket)
|
|
227
|
-
3. **Command presence** → Stdio transport
|
|
250
|
+
3. **Command presence** → Stdio transport (local MCP server)
|
|
228
251
|
4. **Error** if none of the above match
|
|
229
252
|
|
|
230
|
-
This ensures predictable behavior while allowing flexibility for different deployment scenarios.
|
|
253
|
+
This ensures predictable behavior while allowing flexibility for different deployment scenarios.
|
|
254
|
+
**Note:** SSE transport is deprecated as of protocol version 2025-03-26; Streamable HTTP is the recommended approach.
|
|
231
255
|
|
|
232
256
|
### Remote MCP Server Support
|
|
233
257
|
|
|
@@ -246,7 +270,7 @@ This ensures predictable behavior while allowing flexibility for different deplo
|
|
|
246
270
|
// type: "http" // VSCode-style config also works instead of the above
|
|
247
271
|
},
|
|
248
272
|
|
|
249
|
-
// Explicit SSE
|
|
273
|
+
// Explicit SSE (Note: SSE transport is deprecated)
|
|
250
274
|
"sse-server-name": {
|
|
251
275
|
url: `http://${sse_server_host}:${sse_server_port}/...`,
|
|
252
276
|
transport: "sse" // or `type: "sse"`
|
|
@@ -259,7 +283,7 @@ This ensures predictable behavior while allowing flexibility for different deplo
|
|
|
259
283
|
},
|
|
260
284
|
```
|
|
261
285
|
|
|
262
|
-
|
|
286
|
+
The `"headers"` key can be used to pass HTTP headers to Streamable HTTP and SSE connection.
|
|
263
287
|
This header configuration will be overridden if either `streamableHTTPOptions` or `sseOptions` is specified (details below).
|
|
264
288
|
|
|
265
289
|
```ts
|
|
@@ -273,9 +297,6 @@ This header configuration will be overridden if either `streamableHTTPOptions` o
|
|
|
273
297
|
},
|
|
274
298
|
```
|
|
275
299
|
|
|
276
|
-
NOTE: When accessing the GitHub MCP server, [GitHub PAT (Personal Access Token)](https://github.com/settings/personal-access-tokens)
|
|
277
|
-
alone is not enough; your GitHub account must have an active Copilot subscription or be assigned a Copilot license through your organization.
|
|
278
|
-
|
|
279
300
|
**Auto-detection behavior (default):**
|
|
280
301
|
- For HTTP/HTTPS URLs without explicit `transport`, the library follows [MCP specification recommendations](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#backwards-compatibility)
|
|
281
302
|
- First attempts Streamable HTTP transport
|
|
@@ -284,7 +305,7 @@ alone is not enough; your GitHub account must have an active Copilot subscriptio
|
|
|
284
305
|
|
|
285
306
|
**Explicit transport selection:**
|
|
286
307
|
- Set `transport: "streamable_http"` (or VSCode-style config `type: "http"`) to force Streamable HTTP (no fallback)
|
|
287
|
-
- Set `transport: "sse"` to force SSE transport
|
|
308
|
+
- Set `transport: "sse"` to force SSE transport (SSE transport is deprecated)
|
|
288
309
|
- WebSocket URLs (`ws://` or `wss://`) always use WebSocket transport
|
|
289
310
|
|
|
290
311
|
Streamable HTTP is the modern MCP transport that replaces the older HTTP+SSE transport. According to the [official MCP documentation](https://modelcontextprotocol.io/docs/concepts/transports): "SSE as a standalone transport is deprecated as of protocol version 2025-03-26. It has been replaced by Streamable HTTP, which incorporates SSE as an optional streaming mechanism."
|
|
@@ -344,24 +365,13 @@ Test implementations are provided:
|
|
|
344
365
|
- MCP client uses this library: [streamable-http-auth-test-client.ts](https://github.com/hideya/langchain-mcp-tools-ts/tree/main/testfiles/streamable-http-auth-test-client.ts)
|
|
345
366
|
- Test MCP Server: [streamable-http-auth-test-server.ts](https://github.com/hideya/langchain-mcp-tools-ts/tree/main/testfiles/streamable-http-auth-test-server.ts)
|
|
346
367
|
|
|
347
|
-
## API docs
|
|
348
|
-
|
|
349
|
-
Can be found [here](https://hideya.github.io/langchain-mcp-tools-ts/modules.html)
|
|
350
|
-
|
|
351
|
-
## Change Log
|
|
352
|
-
|
|
353
|
-
Can be found [here](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/CHANGELOG.md)
|
|
354
|
-
|
|
355
|
-
## Building from Source
|
|
356
|
-
|
|
357
|
-
See [README_DEV.md](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README_DEV.md) for details.
|
|
358
368
|
|
|
359
369
|
## Appendix
|
|
360
370
|
|
|
361
371
|
### Troubleshooting
|
|
362
372
|
|
|
363
373
|
1. **Enable debug logging**: Set `logLevel: "debug"` to see detailed connection and execution logs
|
|
364
|
-
2. **Check server stderr**: For
|
|
374
|
+
2. **Check server stderr**: For local MCP servers, use `stderr` redirection to capture server error output
|
|
365
375
|
3. **Test explicit transports**: Try forcing specific transport types to isolate auto-detection issues
|
|
366
376
|
4. **Verify server independently**: Refer to [Debugging Section in MCP documentation](https://modelcontextprotocol.io/docs/tools/debugging)
|
|
367
377
|
|
|
@@ -478,3 +488,14 @@ Available log levels: `"fatal" | "error" | "warn" | "info" | "debug" | "trace"`
|
|
|
478
488
|
|
|
479
489
|
See [README_DEV.md](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README_DEV.md)
|
|
480
490
|
for more information about development and testing.
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
## License
|
|
494
|
+
|
|
495
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
496
|
+
|
|
497
|
+
## Contributing
|
|
498
|
+
|
|
499
|
+
[Issues](https://github.com/hideya/langchain-mcp-tools-ts/issues) and
|
|
500
|
+
[pull requests](https://github.com/hideya/langchain-mcp-tools-ts/pulls) welcome!
|
|
501
|
+
In particular, please share any issues relating to the latest versions of LangChain and LLM models, as well as specific MCP servers.
|