@h1deya/langchain-mcp-tools 0.4.0 → 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.
Files changed (2) hide show
  1. package/README.md +67 -31
  2. 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": `${process.env.BRAVE_API_KEY}` }
54
+ env: { "BRAVE_API_KEY": process.env.BRAVE_API_KEY || "" }
51
55
  },
52
56
  github: {
53
57
  type: "http",
@@ -91,10 +95,10 @@ to be invoked to close all MCP server sessions when finished.
91
95
  The returned tools can be used with LangChain, e.g.:
92
96
 
93
97
  ```ts
94
- // import { createAgent } from "langchain";
98
+ // import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
95
99
  const model = new ChatGoogleGenerativeAI({ model: "gemini-2.5-flash" });
96
100
 
97
- // import { createReactAgent } from "@langchain/langgraph/prebuilt";
101
+ // import { createAgent } from "langchain";
98
102
  const agent = createAgent({
99
103
  model,
100
104
  tools
@@ -120,7 +124,7 @@ try {
120
124
  }
121
125
  ```
122
126
 
123
- A minimal but complete working usage example can be found
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,16 +190,28 @@ 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 stdio server configrations if not explicitly provided to ensure servers can find required executables.
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
 
197
+ ### Environment Variable Configuration for Local MCP Server
198
+
199
+ If you need to pass an API key or other configurations to a local MCP server
200
+ via environment variables, use this example as a guide:
201
+
202
+ ```ts
203
+ brave: {
204
+ command: "npx",
205
+ args: [ "-y", "@modelcontextprotocol/server-brave-search"],
206
+ env: { "BRAVE_API_KEY": process.env.BRAVE_API_KEY || "" }
207
+ },
208
+ ```
209
+
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.
211
+
174
212
  ### `stderr` Redirection for Local MCP Server
175
213
 
176
- A new key `"stderr"` has been introduced to specify a file descriptor
177
- to which local (stdio) MCP server's stderr is redirected.
178
- The key name `stderr` is derived from
179
- 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.
180
215
 
181
216
  ```ts
182
217
  const logPath = `mcp-server-${serverName}.log`;
@@ -185,11 +220,14 @@ TypeScript SDK's [`StdioServerParameters`](https://github.com/modelcontextprotoc
185
220
  ```
186
221
 
187
222
  A usage example can be found [here](
188
- https://github.com/hideya/langchain-mcp-tools-ts-usage/blob/694b877ed5336bfcd5274d95d3f6d14bed0937a6/src/index.ts#L72-L83)
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).
189
227
 
190
228
  ### Working Directory Configuration for Local MCP Servers
191
229
 
192
- The working directory that is used when spawning a local (stdio) MCP server
230
+ The working directory that is used when spawning a local MCP server
193
231
  can be specified with the `"cwd"` key as follows:
194
232
 
195
233
  ```ts
@@ -209,10 +247,11 @@ The library selects transports using the following priority order:
209
247
 
210
248
  1. **Explicit transport/type field** (must match URL protocol if URL provided)
211
249
  2. **URL protocol auto-detection** (http/https → StreamableHTTP → SSE, ws/wss → WebSocket)
212
- 3. **Command presence** → Stdio transport
250
+ 3. **Command presence** → Stdio transport (local MCP server)
213
251
  4. **Error** if none of the above match
214
252
 
215
- 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.
216
255
 
217
256
  ### Remote MCP Server Support
218
257
 
@@ -231,7 +270,7 @@ This ensures predictable behavior while allowing flexibility for different deplo
231
270
  // type: "http" // VSCode-style config also works instead of the above
232
271
  },
233
272
 
234
- // Explicit SSE
273
+ // Explicit SSE (Note: SSE transport is deprecated)
235
274
  "sse-server-name": {
236
275
  url: `http://${sse_server_host}:${sse_server_port}/...`,
237
276
  transport: "sse" // or `type: "sse"`
@@ -244,7 +283,7 @@ This ensures predictable behavior while allowing flexibility for different deplo
244
283
  },
245
284
  ```
246
285
 
247
- For the convenience of adding authorization headers, the following shorthand expression is supported.
286
+ The `"headers"` key can be used to pass HTTP headers to Streamable HTTP and SSE connection.
248
287
  This header configuration will be overridden if either `streamableHTTPOptions` or `sseOptions` is specified (details below).
249
288
 
250
289
  ```ts
@@ -258,9 +297,6 @@ This header configuration will be overridden if either `streamableHTTPOptions` o
258
297
  },
259
298
  ```
260
299
 
261
- NOTE: When accessing the GitHub MCP server, [GitHub PAT (Personal Access Token)](https://github.com/settings/personal-access-tokens)
262
- alone is not enough; your GitHub account must have an active Copilot subscription or be assigned a Copilot license through your organization.
263
-
264
300
  **Auto-detection behavior (default):**
265
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)
266
302
  - First attempts Streamable HTTP transport
@@ -269,7 +305,7 @@ alone is not enough; your GitHub account must have an active Copilot subscriptio
269
305
 
270
306
  **Explicit transport selection:**
271
307
  - Set `transport: "streamable_http"` (or VSCode-style config `type: "http"`) to force Streamable HTTP (no fallback)
272
- - Set `transport: "sse"` to force SSE transport
308
+ - Set `transport: "sse"` to force SSE transport (SSE transport is deprecated)
273
309
  - WebSocket URLs (`ws://` or `wss://`) always use WebSocket transport
274
310
 
275
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."
@@ -329,24 +365,13 @@ Test implementations are provided:
329
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)
330
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)
331
367
 
332
- ## API docs
333
-
334
- Can be found [here](https://hideya.github.io/langchain-mcp-tools-ts/modules.html)
335
-
336
- ## Change Log
337
-
338
- Can be found [here](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/CHANGELOG.md)
339
-
340
- ## Building from Source
341
-
342
- See [README_DEV.md](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README_DEV.md) for details.
343
368
 
344
369
  ## Appendix
345
370
 
346
371
  ### Troubleshooting
347
372
 
348
373
  1. **Enable debug logging**: Set `logLevel: "debug"` to see detailed connection and execution logs
349
- 2. **Check server stderr**: For stdio MCP servers, use `stderr` redirection to capture server error output
374
+ 2. **Check server stderr**: For local MCP servers, use `stderr` redirection to capture server error output
350
375
  3. **Test explicit transports**: Try forcing specific transport types to isolate auto-detection issues
351
376
  4. **Verify server independently**: Refer to [Debugging Section in MCP documentation](https://modelcontextprotocol.io/docs/tools/debugging)
352
377
 
@@ -463,3 +488,14 @@ Available log levels: `"fatal" | "error" | "warn" | "info" | "debug" | "trace"`
463
488
 
464
489
  See [README_DEV.md](https://github.com/hideya/langchain-mcp-tools-ts/blob/main/README_DEV.md)
465
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h1deya/langchain-mcp-tools",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "MCP To LangChain Tools Conversion Utility",
5
5
  "license": "MIT",
6
6
  "keywords": [