mcp2postman 1.0.0__tar.gz

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 (36) hide show
  1. mcp2postman-1.0.0/CHANGELOG.md +58 -0
  2. mcp2postman-1.0.0/LICENSE.md +202 -0
  3. mcp2postman-1.0.0/MANIFEST.in +4 -0
  4. mcp2postman-1.0.0/PKG-INFO +406 -0
  5. mcp2postman-1.0.0/README.md +376 -0
  6. mcp2postman-1.0.0/examples/demo.postman_collection.json +3963 -0
  7. mcp2postman-1.0.0/examples/demo.postman_environment.json +13 -0
  8. mcp2postman-1.0.0/examples/demo.snapshot.json +151 -0
  9. mcp2postman-1.0.0/examples/demo_server.py +373 -0
  10. mcp2postman-1.0.0/examples/values.json +4 -0
  11. mcp2postman-1.0.0/pyproject.toml +61 -0
  12. mcp2postman-1.0.0/setup.cfg +4 -0
  13. mcp2postman-1.0.0/src/mcp2postman/__init__.py +5 -0
  14. mcp2postman-1.0.0/src/mcp2postman/__main__.py +5 -0
  15. mcp2postman-1.0.0/src/mcp2postman/cli.py +358 -0
  16. mcp2postman-1.0.0/src/mcp2postman/client.py +383 -0
  17. mcp2postman-1.0.0/src/mcp2postman/config.py +218 -0
  18. mcp2postman-1.0.0/src/mcp2postman/discovery.py +125 -0
  19. mcp2postman-1.0.0/src/mcp2postman/mcp_schemas.py +216 -0
  20. mcp2postman-1.0.0/src/mcp2postman/postman.py +689 -0
  21. mcp2postman-1.0.0/src/mcp2postman/schema_values.py +436 -0
  22. mcp2postman-1.0.0/src/mcp2postman/scripts.py +278 -0
  23. mcp2postman-1.0.0/src/mcp2postman.egg-info/PKG-INFO +406 -0
  24. mcp2postman-1.0.0/src/mcp2postman.egg-info/SOURCES.txt +34 -0
  25. mcp2postman-1.0.0/src/mcp2postman.egg-info/dependency_links.txt +1 -0
  26. mcp2postman-1.0.0/src/mcp2postman.egg-info/entry_points.txt +2 -0
  27. mcp2postman-1.0.0/src/mcp2postman.egg-info/requires.txt +4 -0
  28. mcp2postman-1.0.0/src/mcp2postman.egg-info/top_level.txt +1 -0
  29. mcp2postman-1.0.0/tests/conftest.py +42 -0
  30. mcp2postman-1.0.0/tests/helpers.py +17 -0
  31. mcp2postman-1.0.0/tests/test_cli.py +116 -0
  32. mcp2postman-1.0.0/tests/test_client.py +113 -0
  33. mcp2postman-1.0.0/tests/test_config.py +94 -0
  34. mcp2postman-1.0.0/tests/test_e2e_postman.py +64 -0
  35. mcp2postman-1.0.0/tests/test_postman.py +248 -0
  36. mcp2postman-1.0.0/tests/test_schema_values.py +119 -0
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2026-11-11
4
+
5
+ First release published on PyPI: `pip install mcp2postman`.
6
+
7
+ ### Added
8
+ - Support for MCP protocol versions `2026-07-28`, `2025-11-25` and
9
+ `2025-06-18`. Discovery proposes the newest one and, when a server rejects
10
+ it with an error instead of negotiating, retries with the next older one.
11
+ Connection failures are not retried. A negotiated version outside the list
12
+ is reported as a snapshot warning. (SA-3290)
13
+ - New "91 Protocol versions" folder: one `initialize` per version plus an
14
+ unknown version (`1999-01-01`), checking the negotiation rules without
15
+ touching `mcpSessionId`. `--protocol-versions V1,V2` (or `none`) selects the
16
+ versions, and `--no-protocol-tests` also skips the folder. (SA-3290)
17
+ - Package metadata for PyPI: project URLs, supported Python versions
18
+ (3.10 to 3.13) and a source distribution that includes the tests and
19
+ examples.
20
+
21
+ ### Changed
22
+ - The tool is now called `mcp2postman`, like the repository: package on PyPI,
23
+ Python module (`import mcp2postman`, `python -m mcp2postman`), command,
24
+ MCP `clientInfo` name and `User-Agent`. Snapshots now use the format
25
+ `mcp2postman/snapshot@1`; regenerate snapshots saved by 0.x versions.
26
+ - Each `tool: <name>` folder now holds one subfolder per test kind
27
+ ("valid", "missing required -> error", "wrong type -> error"), so a single
28
+ kind of test can be run or reviewed on its own. Empty kinds, for example
29
+ with `--no-negative-tests`, are left out. (SA-3277)
30
+ - The README installs from PyPI and uses absolute links, so it renders on the
31
+ PyPI project page.
32
+
33
+ ### Removed
34
+ - Python 3.9 support. It reached end of life in October 2025 and is no longer
35
+ available on the CI runners. Python 3.10 or later is required.
36
+
37
+ ## 0.2.0 - 2026-11-05
38
+
39
+ ### Added
40
+ - `--body-variables`: tool and prompt argument values move from request
41
+ bodies into environment variables (`{{<tool>_<arg>}}`,
42
+ `{{prompt_<prompt>_<arg>}}`). Non-string values are inserted without quotes,
43
+ so their JSON type is kept. (SA-3276)
44
+ - `--config` / `--server`: read the server and its auth from an
45
+ `mcp-config.json`.
46
+
47
+ ### Changed
48
+ - The Postman environment file is always written, next to the collection by
49
+ default, and always contains `baseUrl`. `--environment-out` only sets its
50
+ path. (SA-3276)
51
+ - Test scripts resolve variables before reading the JSON-RPC request id.
52
+ - The client sends its own `User-Agent`.
53
+
54
+ ## 0.1.0
55
+
56
+ - First release: MCP (Streamable HTTP or stdio) to Postman collection, with
57
+ tests for required and optional attributes, response schema validation and
58
+ drift checks. (SA-3275)
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ include CHANGELOG.md
2
+ recursive-include tests *.py
3
+ recursive-include examples *.py *.json
4
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,406 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp2postman
3
+ Version: 1.0.0
4
+ Summary: Convert an MCP server (Streamable HTTP or stdio) into a Postman collection with contract, required and optional attribute tests.
5
+ Author-email: APIAddicts <devrel@apiaddicts.org>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/apiaddicts/mcp2postman
8
+ Project-URL: Repository, https://github.com/apiaddicts/mcp2postman
9
+ Project-URL: Issues, https://github.com/apiaddicts/mcp2postman/issues
10
+ Project-URL: Changelog, https://github.com/apiaddicts/mcp2postman/blob/main/CHANGELOG.md
11
+ Keywords: mcp,model-context-protocol,postman,testing,json-rpc,cli
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE.md
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7; extra == "dev"
28
+ Requires-Dist: ruff>=0.4; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # mcp2postman
32
+
33
+ [![PyPI version](https://img.shields.io/pypi/v/mcp2postman.svg)](https://pypi.org/project/mcp2postman/)
34
+ [![Python versions](https://img.shields.io/pypi/pyversions/mcp2postman.svg)](https://pypi.org/project/mcp2postman/)
35
+ [![Downloads](https://static.pepy.tech/badge/mcp2postman/month)](https://pepy.tech/project/mcp2postman)
36
+ [![CI](https://github.com/apiaddicts/mcp2postman/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/apiaddicts/mcp2postman/actions/workflows/ci.yml)
37
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/apiaddicts/mcp2postman/blob/main/LICENSE.md)
38
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
39
+
40
+ Turn an **MCP server** (Model Context Protocol) into a **Postman collection** that
41
+ initializes a session, calls every tool, resource and prompt, and **tests the
42
+ responses**. The tests check that responses follow the MCP schema, that the
43
+ server still matches the contract it published, and that required and optional
44
+ attributes behave as declared.
45
+
46
+ ```
47
+ MCP server ──(initialize, tools/list, resources/list, prompts/list)──▶ snapshot ──▶ Postman collection
48
+ (HTTP or stdio) + environment
49
+ ```
50
+
51
+ * Works with **Streamable HTTP** servers (`--url`) and **stdio** servers (`--stdio`).
52
+ * Handles both `application/json` and `text/event-stream` (SSE) responses, in
53
+ the CLI and in the generated Postman scripts.
54
+ * Builds **positive and negative tests** for each tool, based on its `inputSchema`:
55
+ * valid call with all attributes,
56
+ * valid call with required attributes only,
57
+ * valid call with the required attributes plus one optional attribute, for each optional attribute,
58
+ * call without each required attribute, which must be rejected,
59
+ * call with a wrong type for each attribute, which must be rejected.
60
+ * **Validates responses** with JSON Schema: `InitializeResult`, `CallToolResult`,
61
+ `structuredContent` against the tool's `outputSchema`, `ReadResourceResult`,
62
+ `GetPromptResult`, and the JSON-RPC error shape.
63
+ * **Always writes a Postman environment** next to the collection, with
64
+ `baseUrl` and the header variables. With `--body-variables`, the tool and
65
+ prompt argument values move from the request bodies into that environment.
66
+ * **Detects drift.** `tools/list` and `prompts/list` fail when a tool or prompt
67
+ disappears or its input schema changes after the collection was generated.
68
+ * Has no runtime dependencies (Python ≥ 3.10 standard library only).
69
+ * Licensed under Apache 2.0.
70
+
71
+ ## Installation
72
+
73
+ ```bash
74
+ pip install mcp2postman
75
+ ```
76
+
77
+ This installs the `mcp2postman` command. You can also run it with
78
+ `python -m mcp2postman`.
79
+
80
+ To install the latest development version from GitHub, or from a local clone:
81
+
82
+ ```bash
83
+ pip install git+https://github.com/apiaddicts/mcp2postman.git
84
+ # or, from a clone
85
+ pip install -e .
86
+ ```
87
+
88
+ ## Quick start
89
+
90
+ Try it with the bundled demo server:
91
+
92
+ ```bash
93
+ python examples/demo_server.py --http --port 8765 &
94
+
95
+ mcp2postman inspect --url http://localhost:8765/mcp
96
+ mcp2postman generate --url http://localhost:8765/mcp -o demo.postman_collection.json
97
+ # -> demo.postman_collection.json + demo.postman_environment.json
98
+
99
+ # run it (any of these)
100
+ postman collection run demo.postman_collection.json -e demo.postman_environment.json
101
+ newman run demo.postman_collection.json -e demo.postman_environment.json
102
+ ```
103
+
104
+ Output of `inspect`:
105
+
106
+ ```
107
+ Demo MCP Server 1.0.0
108
+ protocol: 2025-06-18
109
+ capabilities: prompts, resources, tools
110
+
111
+ Tools (3):
112
+ - add(a*, b*)
113
+ - greet(name*, language, excited)
114
+ - search_items(query*, limit, tags, filters)
115
+ ...
116
+ (* = required)
117
+ ```
118
+
119
+ With the demo server, the generated collection has 42 requests and 176
120
+ assertions, and all of them pass. `examples/demo.postman_collection.json` is
121
+ an example of the output.
122
+
123
+ You can also import the collection into the Postman app (*Import → File*).
124
+ **Run the `00 Lifecycle` folder first.** It opens the MCP session and stores
125
+ `Mcp-Session-Id` and the negotiated protocol version, and the other requests
126
+ use those values.
127
+
128
+ ## Usage
129
+
130
+ ### `generate`
131
+
132
+ ```text
133
+ mcp2postman generate (--url URL | --stdio COMMAND | --config FILE | --from-snapshot FILE) [options]
134
+ ```
135
+
136
+ | Option | Description |
137
+ |---|---|
138
+ | `--url URL` | Streamable HTTP endpoint, for example `http://localhost:3000/mcp` |
139
+ | `--stdio "CMD"` | Command that starts a stdio server, for example `"npx -y @modelcontextprotocol/server-everything"` |
140
+ | `--config FILE` | Read the server (URL or command, args, env, cwd) and its auth headers from an `mcp-config.json`. See [MCP config files](#mcp-config-files) |
141
+ | `--server NAME` | Server to use when the config file defines several |
142
+ | `--from-snapshot FILE` | Generate offline from a snapshot saved earlier |
143
+ | `-H 'Name: value'` | Extra HTTP header (repeatable). Typical use: `-H 'Authorization: Bearer …'`. Overrides a config header with the same name |
144
+ | `--env KEY=VALUE` | Environment variable for the stdio server (repeatable). Overrides the config `env` |
145
+ | `-o FILE` | Collection output file (`-` for stdout). The default is `<server>.postman_collection.json` |
146
+ | `--environment-out FILE` | Path of the Postman environment, which is always written. It holds `baseUrl`, the header variables and, with `--body-variables`, the argument values. The default is the collection path with `.postman_environment.json` (`<server>.postman_environment.json` when `-o -`) |
147
+ | `--body-variables` | Put tool and prompt argument values in environment variables (`{{tool_arg}}`) instead of writing them into the request bodies. See [Body variables](#body-variables) |
148
+ | `--snapshot-out FILE` | Also save the discovered server snapshot |
149
+ | `--base-url URL` | Value of `{{baseUrl}}`. The default is `--url`, or `http://localhost:3000/mcp` for stdio |
150
+ | `--name NAME` | Collection name |
151
+ | `--embed-header-values` | Write `-H` values into the collection and environment (see [Secrets](#secrets)) |
152
+ | `--include-tool GLOB` / `--exclude-tool GLOB` | Choose which tools get requests (repeatable) |
153
+ | `--values FILE` | Argument values for each tool, which replace the generated samples |
154
+ | `--no-negative-tests` | Do not generate the *missing required* and *wrong type* requests |
155
+ | `--no-wrong-type-tests` | Do not generate the *wrong type* requests |
156
+ | `--no-optional-variants` | Do not generate one request per optional attribute |
157
+ | `--no-protocol-tests` | Do not generate the generic JSON-RPC checks (unknown method, unknown tool) or the protocol version checks |
158
+ | `--protocol-versions V1,V2` | Protocol versions checked in the `91 Protocol versions` folder. The default is every supported version (`2026-07-28,2025-11-25,2025-06-18`), and `none` leaves the folder out |
159
+ | `--no-resources` / `--no-prompts` / `--no-teardown` | Leave out those folders |
160
+ | `--protocol-version V` | Protocol version proposed in `initialize`. By default the newest supported version (`2026-07-28`) is proposed. If the server rejects it instead of negotiating, discovery retries with `2025-11-25`, then `2025-06-18` |
161
+ | `--timeout S` | Seconds to wait for each response during discovery |
162
+
163
+ ### `inspect`
164
+
165
+ ```text
166
+ mcp2postman inspect (--url URL | --stdio COMMAND | --config FILE [--server NAME]) [-H ...] [--json]
167
+ ```
168
+
169
+ Prints the server's tools (required attributes are marked with `*`), resources
170
+ and prompts. With `--json`, it prints the full snapshot instead.
171
+
172
+ ### Realistic argument values
173
+
174
+ The generator creates sample values from each JSON schema. It uses `const`,
175
+ `default`, `examples`, `enum`, `format`, bounds, `pattern`, `$ref`, `anyOf`,
176
+ `oneOf` and `allOf`. When a tool needs real data, such as an existing ID, put
177
+ it in a values file:
178
+
179
+ ```json
180
+ {
181
+ "add": { "a": 40, "b": 2 },
182
+ "greet": { "name": "Ada", "language": "es" }
183
+ }
184
+ ```
185
+
186
+ ```bash
187
+ mcp2postman generate --url … --values examples/values.json
188
+ ```
189
+
190
+ ### Body variables
191
+
192
+ By default, argument values are written straight into each request body. With
193
+ `--body-variables`, every top-level tool argument becomes the variable
194
+ `{{<tool>_<argument>}}`, and every prompt argument becomes
195
+ `{{prompt_<prompt>_<argument>}}`. The values go into the environment file, so
196
+ you can change test data without regenerating the collection or editing
197
+ requests.
198
+
199
+ ```bash
200
+ mcp2postman generate --url http://localhost:8765/mcp --body-variables \
201
+ --values examples/values.json -o demo.postman_collection.json
202
+ ```
203
+
204
+ Request body:
205
+
206
+ ```json
207
+ {
208
+ "jsonrpc": "2.0",
209
+ "id": 4,
210
+ "method": "tools/call",
211
+ "params": {
212
+ "name": "add",
213
+ "arguments": {
214
+ "a": {{add_a}},
215
+ "b": {{add_b}}
216
+ }
217
+ }
218
+ }
219
+ ```
220
+
221
+ Environment (`demo.postman_environment.json`):
222
+
223
+ | key | value |
224
+ |---|---|
225
+ | `baseUrl` | `http://localhost:8765/mcp` |
226
+ | `add_a` | `40` |
227
+ | `add_b` | `2` |
228
+ | `greet_name` | `Ada` |
229
+ | `search_items_filters` | `{"inStock": true}` |
230
+ | `prompt_summarize_text` | `example-text` |
231
+
232
+ How values are stored:
233
+
234
+ * **Strings** are used inside quotes (`"{{greet_name}}"`). The environment
235
+ holds the text with JSON escaping, so `"` becomes `\"`.
236
+ * **Numbers, booleans, null, arrays and objects** are used without quotes
237
+ (`{{add_a}}`) and stored as JSON literals (`40`, `true`, `["a"]`,
238
+ `{"inStock": true}`), so the server still receives the right JSON type.
239
+ * The valid variants of a tool (all attributes, required only, one per
240
+ optional attribute) and its *missing required* requests share the same
241
+ variables. *Wrong type* requests keep their deliberately invalid value as a
242
+ literal.
243
+ * `--values` sets the initial values in the environment.
244
+
245
+ Raw bodies containing unquoted `{{…}}` aren't valid JSON until Postman
246
+ substitutes the variables, so **always run the collection with its
247
+ environment** (`-e`).
248
+
249
+ ### MCP config files
250
+
251
+ Reuse the `mcp-config.json` you already give to Claude Desktop, Claude Code
252
+ (`.mcp.json`), Cursor or VS Code (`.vscode/mcp.json`) instead of repeating the
253
+ URL, command and credentials on the command line:
254
+
255
+ ```json
256
+ {
257
+ "mcpServers": {
258
+ "corecast": {
259
+ "type": "http",
260
+ "url": "https://aigw-wso2.apiquality.io/mcp-corecast/1/mcp",
261
+ "headers": { "Authorization": "Bearer ${CORECAST_TOKEN}" }
262
+ },
263
+ "local": {
264
+ "command": "python",
265
+ "args": ["examples/demo_server.py", "--stdio"],
266
+ "env": { "API_KEY": "${API_KEY}" }
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ ```bash
273
+ export CORECAST_TOKEN=…
274
+ mcp2postman generate --config mcp-config.json --server corecast -o corecast.postman_collection.json
275
+ ```
276
+
277
+ * Accepted layouts: `{"mcpServers": {…}}`, VS Code's `{"servers": {…}, "inputs": […]}`,
278
+ or a single server object. `--server` is only needed when there are several.
279
+ * HTTP servers use `url`, `headers` and an optional `type` (`http` or
280
+ `streamable-http`). The legacy `sse` type is rejected. stdio servers use
281
+ `command`, `args`, `env` and `cwd` (relative to the config file).
282
+ * Keep secrets out of the file with `${VAR}`, `${env:VAR}` or `${VAR:-default}`
283
+ (read from the environment, and an unset variable is an error). VS Code
284
+ `${input:id}` values are prompted for on the terminal, hidden when the input
285
+ has `"password": true`.
286
+ * Config headers are handled like `-H` headers: they're sent during discovery
287
+ and become empty `{{header_…}}` variables in the collection (see
288
+ [Secrets](#secrets)). The snapshot only records the file and server name,
289
+ never the header or env values.
290
+
291
+ ### stdio servers
292
+
293
+ Postman can only send HTTP requests. For a stdio server, the CLI starts the
294
+ process to discover what it exposes, but the collection targets `{{baseUrl}}`.
295
+ To run the collection, expose the server over Streamable HTTP, for example with
296
+ a stdio-to-HTTP bridge, and pass `--base-url` or edit the variable:
297
+
298
+ ```bash
299
+ mcp2postman generate --stdio "python examples/demo_server.py --stdio" \
300
+ --base-url http://localhost:8000/mcp
301
+ ```
302
+
303
+ ### Secrets
304
+
305
+ By default, every `-H` header is sent to the server during discovery. In the
306
+ collection, it becomes a reference to an **empty** variable (`Authorization:
307
+ {{header_authorization}}`), so you don't commit credentials by accident. Supply
308
+ the value when you run the collection:
309
+
310
+ ```bash
311
+ postman collection run c.json --env-var "header_authorization=Bearer $TOKEN"
312
+ newman run c.json --env-var "header_authorization=Bearer $TOKEN"
313
+ ```
314
+
315
+ To store the values in the collection and environment files, use
316
+ `--embed-header-values`.
317
+
318
+ ### Snapshots and CI
319
+
320
+ ```bash
321
+ # once: discover and store the contract
322
+ mcp2postman generate --url $MCP_URL --snapshot-out mcp.snapshot.json -o mcp.postman_collection.json
323
+ git add mcp.snapshot.json mcp.postman_collection.json mcp.postman_environment.json
324
+
325
+ # in CI: run the collection against the deployed server
326
+ postman collection run mcp.postman_collection.json -e mcp.postman_environment.json --env-var "baseUrl=$MCP_URL"
327
+ ```
328
+
329
+ If someone removes a tool or changes its `inputSchema`, the `tools/list`
330
+ drift tests fail.
331
+
332
+ ## What the collection contains
333
+
334
+ ```
335
+ <Server> (MCP)
336
+ ├── 00 Lifecycle
337
+ │ ├── initialize → stores Mcp-Session-Id + protocolVersion
338
+ │ ├── notifications/initialized → 202 Accepted
339
+ │ └── ping
340
+ ├── 01 Tools
341
+ │ ├── tools/list → schema + drift checks
342
+ │ ├── tool: <name>
343
+ │ │ ├── valid
344
+ │ │ │ ├── <name> - valid, all attributes
345
+ │ │ │ ├── <name> - valid, required attributes only
346
+ │ │ │ └── <name> - valid, required + optional '<opt>' (one per optional attribute)
347
+ │ │ ├── missing required -> error
348
+ │ │ │ └── <name> - missing required '<req>' -> error (one per required attribute)
349
+ │ │ └── wrong type -> error
350
+ │ │ └── <name> - wrong type for required|optional '<attr>' -> error
351
+ │ └── tools/call unknown tool -> error
352
+ ├── 02 Resources resources/list, resources/templates/list, resources/read <each>, missing uri -> error
353
+ ├── 03 Prompts prompts/list, prompts/get (all / required only / missing required -> error)
354
+ ├── 90 Protocol unknown method -> -32601
355
+ ├── 91 Protocol versions initialize with <each version> + an unknown version (negotiation rules)
356
+ └── 99 Teardown DELETE session
357
+ ```
358
+
359
+ **Valid calls** pass when the HTTP status is 200, the body contains a JSON-RPC
360
+ 2.0 response with the request's `id`, there is no `error`, the `result` matches
361
+ the MCP schema, `isError` is not `true`, and `structuredContent` matches the
362
+ tool's `outputSchema` when the tool declares one.
363
+
364
+ **Invalid calls** pass when the server rejects them, either with a JSON-RPC
365
+ `error` or with a tool result that has `isError: true`. The MCP specification
366
+ allows both. The error payload must also be well formed, and the server must
367
+ not answer with a 5xx status.
368
+
369
+ **Protocol version checks** (`91 Protocol versions`) send one `initialize` per
370
+ version. The server must answer with a version mcp2postman supports, must
371
+ keep the version that discovery negotiated, and must not echo the unknown
372
+ version `1999-01-01`. Each request opens its own session and doesn't change
373
+ `{{mcpSessionId}}`.
374
+
375
+ > ⚠️ The collection **really calls every tool**, several times. Don't run it
376
+ > against tools with side effects (sending email, payments, deletes) on a
377
+ > production server. Use `--exclude-tool` or `--values`, or point it at a test
378
+ > environment.
379
+
380
+ ## Development
381
+
382
+ ```bash
383
+ python -m venv .venv && . .venv/bin/activate
384
+ pip install -e '.[dev]'
385
+ pytest # unit + integration tests (end-to-end tests run when newman or postman CLI is installed)
386
+ ruff check .
387
+ ```
388
+
389
+ See [ARCHITECTURE.md](https://github.com/apiaddicts/mcp2postman/blob/main/ARCHITECTURE.md) for how the code is organized.
390
+
391
+ ## Limitations
392
+
393
+ * The legacy HTTP+SSE transport (protocol 2024-11-05, separate `/sse` and
394
+ `/messages` endpoints) isn't supported. Use Streamable HTTP or stdio.
395
+ * OAuth flows aren't automated (an `oauth` block in a config file is ignored).
396
+ Get a token yourself and pass it with `-H` or a `${VAR}` config header.
397
+ * Generated values satisfy common JSON Schema constraints. A complex `pattern`
398
+ or semantic constraints, such as an ID that has to exist, may need `--values`.
399
+ * The `tools/list` drift checks only look at the first page when the server
400
+ paginates.
401
+
402
+ ## License
403
+
404
+ Apache License 2.0. See [LICENSE.md](https://github.com/apiaddicts/mcp2postman/blob/main/LICENSE.md).
405
+
406
+ Changes between versions are listed in the [changelog](https://github.com/apiaddicts/mcp2postman/blob/main/CHANGELOG.md).