Skip to content

Commit af4092c

Browse files
committed
chore(docs): Add examples of server parameters
Resolves #499
1 parent 3fd81b2 commit af4092c

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,103 @@ This library supports connecting to Lambda-based MCP servers in four ways:
5353
1. A custom Streamable HTTP transport with support for SigV4, using a Lambda function URL. Authenticated with AWS IAM.
5454
1. A custom Lambda invocation transport, using the Lambda Invoke API directly. Authenticated with AWS IAM.
5555

56+
## Determine your server parameters
57+
58+
Many stdio-based MCP servers's documentation encourages using tools that download and run the server on-demand.
59+
For example, `uvx my-mcp-server` or `npx my-mcp-server`.
60+
These tools are often not pre-packaged in the Lambda environment, and it can be inefficient to
61+
re-download the server on every Lambda invocation.
62+
63+
Instead, the examples in this repository show how to package the MCP server along with
64+
the Lambda function code, then start it with `python` or `node` (or `npx --offline`) directly.
65+
66+
You will need to determine the right parameters depending on your MCP server's package.
67+
This can often be a trial and error process locally, since MCP server packaging varies.
68+
69+
<details>
70+
71+
<summary><b>Python server examples</b></summary>
72+
73+
Basic example:
74+
75+
```python
76+
from mcp.client.stdio import StdioServerParameters
77+
78+
server_params = StdioServerParameters(
79+
command=sys.executable,
80+
args=[
81+
"-m",
82+
"my_mcp_server_python_module",
83+
"--my-server-command-line-parameter",
84+
"some_value",
85+
],
86+
)
87+
```
88+
89+
Locally, you would run this module using:
90+
91+
```bash
92+
python -m my_mcp_server_python_module --my-server-command-line-parameter some_value
93+
```
94+
95+
Other examples:
96+
97+
```bash
98+
python -m mcpdoc.cli # Note the sub-module
99+
100+
python -c "from mcp_openapi_proxy import main; main()"
101+
102+
python -c "import asyncio; from postgres_mcp.server import main; asyncio.run(main())"
103+
```
104+
105+
If you use Lambda layers, you need to also set the PYTHONPATH for the python sub-process:
106+
107+
```python
108+
lambda_paths = ["/opt/python"] + sys.path
109+
env_config = {"PYTHONPATH": ":".join(lambda_paths)}
110+
111+
server_params = StdioServerParameters(
112+
command=sys.executable,
113+
args=[
114+
"-c",
115+
"from mcp_openapi_proxy import main; main()",
116+
],
117+
env=env_config,
118+
)
119+
```
120+
</details>
121+
122+
<details>
123+
124+
<summary><b>Typescript server examples</b></summary>
125+
126+
Basic example:
127+
128+
```typescript
129+
const serverParams = {
130+
command: "npx",
131+
args: [
132+
"--offline",
133+
"my-mcp-server-typescript-module",
134+
"--my-server-command-line-parameter",
135+
"some_value",
136+
],
137+
};
138+
```
139+
140+
Locally, you would run this module using:
141+
142+
```bash
143+
npx --offline my-mcp-server-typescript-module --my-server-command-line-parameter some_value
144+
```
145+
146+
Other examples:
147+
```bash
148+
node /var/task/node_modules/@ivotoby/openapi-mcp-server/bin/mcp-server.js
149+
```
150+
151+
</details>
152+
56153
## Use API Gateway
57154

58155
```mermaid

0 commit comments

Comments
 (0)