mcp-api-test 0.1.2__tar.gz → 0.1.3__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 (23) hide show
  1. mcp_api_test-0.1.3/PKG-INFO +112 -0
  2. mcp_api_test-0.1.3/README.md +81 -0
  3. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/pyproject.toml +3 -2
  4. mcp_api_test-0.1.3/src/mcp_api_test.egg-info/PKG-INFO +112 -0
  5. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/mcp_api_test.egg-info/requires.txt +3 -0
  6. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/server.py +22 -6
  7. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/utils.py +13 -10
  8. mcp_api_test-0.1.2/PKG-INFO +0 -334
  9. mcp_api_test-0.1.2/README.md +0 -305
  10. mcp_api_test-0.1.2/src/mcp_api_test.egg-info/PKG-INFO +0 -334
  11. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/LICENSE +0 -0
  12. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/MANIFEST.in +0 -0
  13. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/setup.cfg +0 -0
  14. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/__main__.py +0 -0
  15. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/logger.py +0 -0
  16. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/mcp_api_test.egg-info/SOURCES.txt +0 -0
  17. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/mcp_api_test.egg-info/dependency_links.txt +0 -0
  18. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/mcp_api_test.egg-info/entry_points.txt +0 -0
  19. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/mcp_api_test.egg-info/top_level.txt +0 -0
  20. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/src/models.py +0 -0
  21. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/tests/test_mcp_api_tools.py +0 -0
  22. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/tests/test_parse_curl_command.py +0 -0
  23. {mcp_api_test-0.1.2 → mcp_api_test-0.1.3}/tests/test_parse_status_code.py +0 -0
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-api-test
3
+ Version: 0.1.3
4
+ Summary: MCP server for testing REST API with built-in assertions
5
+ Author: Ryan Febriansyah
6
+ License-Expression: MIT
7
+ Keywords: testing,mcp,llm
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Natural Language :: English
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp
22
+ Requires-Dist: httpx
23
+ Requires-Dist: python-dotenv
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Requires-Dist: pytest-asyncio; extra == "dev"
27
+ Requires-Dist: respx; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: mkdocs-material; extra == "docs"
30
+ Dynamic: license-file
31
+
32
+ # mcp-api-test
33
+
34
+ ![pipeline](https://gitlab.com/ryaneatfood/mcp-api-testing/badges/master/pipeline.svg)
35
+
36
+ An AI-native API testing engine that enables LLM agents to execute, validate, and reason about REST APIs using natural language or cURL inputs.
37
+
38
+ Unlike traditional testing frameworks, `mcp-api-test` exposes API testing as a **first-class capability for AI agents** rather than a developer-facing tool. LLM-powered clients invoke the `run_test_api` tool directly, making API validation a building block for autonomous coding agents, not a separate human-driven workflow.
39
+
40
+ It complements (rather than replaces) tools like pytest, Postman, and Playwright.
41
+
42
+ ## Use cases
43
+
44
+ - **QA & test engineering**: prompt an agent with natural language instead of crafting Postman requests
45
+ - **Post-deployment regression**: have an agent smoke-test critical paths after a deploy
46
+ - **Quick validation**: test an endpoint inline during a coding session
47
+ - **CI/CD automation**: agents validate deployments autonomously in pipelines
48
+
49
+ > **Token efficiency.** Agents get deterministic, structured results in a single tool call instead of parsing raw `curl` output. Fewer tokens, fewer hallucinations.
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install mcp-api-test
55
+ ```
56
+
57
+ Or from source:
58
+
59
+ ```bash
60
+ git clone git@gitlab.com:ryaneatfood/mcp-api-testing.git
61
+ cd mcp-api-testing
62
+ pip install -e .
63
+ ```
64
+
65
+ Requires Python >= 3.10.
66
+
67
+ ## Quick start
68
+
69
+ Configure your MCP client to use the server. For **OpenCode**, add to `opencode.json`:
70
+
71
+ ```json
72
+ {
73
+ "mcp": {
74
+ "mcp-api-test": {
75
+ "type": "local",
76
+ "command": ["mcp-api-test"],
77
+ "enabled": true
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ For **Claude Desktop**, add to `claude_desktop_config.json`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "mcp-api-test": {
89
+ "command": "mcp-api-test"
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ Then prompt your agent:
96
+
97
+ > "Test this API: `curl -X POST https://api.example.com/v1/users -H 'Authorization: Bearer xxx' -d '{"name":"test"}'`, ensure status code is 201 and response contains 'id'"
98
+
99
+ The agent invokes `run_test_api`, validates against the expected contract, and returns structured pass/fail results.
100
+
101
+ ## Documentation
102
+
103
+ Full documentation is hosted on [GitLab Pages](https://ryaneatfood.gitlab.io/mcp-api-testing/) (or build locally with `mkdocs serve`).
104
+
105
+ - **[Getting Started](docs/getting-started/installation.md)**: installation and client setup
106
+ - **[Usage](docs/usage/request-modes.md)**: cURL mode, structured mode, assertions, response format
107
+ - **[Guides](docs/guides/troubleshooting.md)**: troubleshooting, development, configuration
108
+ - **[Reference](docs/reference/tool-parameters.md)**: full parameter reference
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,81 @@
1
+ # mcp-api-test
2
+
3
+ ![pipeline](https://gitlab.com/ryaneatfood/mcp-api-testing/badges/master/pipeline.svg)
4
+
5
+ An AI-native API testing engine that enables LLM agents to execute, validate, and reason about REST APIs using natural language or cURL inputs.
6
+
7
+ Unlike traditional testing frameworks, `mcp-api-test` exposes API testing as a **first-class capability for AI agents** rather than a developer-facing tool. LLM-powered clients invoke the `run_test_api` tool directly, making API validation a building block for autonomous coding agents, not a separate human-driven workflow.
8
+
9
+ It complements (rather than replaces) tools like pytest, Postman, and Playwright.
10
+
11
+ ## Use cases
12
+
13
+ - **QA & test engineering**: prompt an agent with natural language instead of crafting Postman requests
14
+ - **Post-deployment regression**: have an agent smoke-test critical paths after a deploy
15
+ - **Quick validation**: test an endpoint inline during a coding session
16
+ - **CI/CD automation**: agents validate deployments autonomously in pipelines
17
+
18
+ > **Token efficiency.** Agents get deterministic, structured results in a single tool call instead of parsing raw `curl` output. Fewer tokens, fewer hallucinations.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install mcp-api-test
24
+ ```
25
+
26
+ Or from source:
27
+
28
+ ```bash
29
+ git clone git@gitlab.com:ryaneatfood/mcp-api-testing.git
30
+ cd mcp-api-testing
31
+ pip install -e .
32
+ ```
33
+
34
+ Requires Python >= 3.10.
35
+
36
+ ## Quick start
37
+
38
+ Configure your MCP client to use the server. For **OpenCode**, add to `opencode.json`:
39
+
40
+ ```json
41
+ {
42
+ "mcp": {
43
+ "mcp-api-test": {
44
+ "type": "local",
45
+ "command": ["mcp-api-test"],
46
+ "enabled": true
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ For **Claude Desktop**, add to `claude_desktop_config.json`:
53
+
54
+ ```json
55
+ {
56
+ "mcpServers": {
57
+ "mcp-api-test": {
58
+ "command": "mcp-api-test"
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ Then prompt your agent:
65
+
66
+ > "Test this API: `curl -X POST https://api.example.com/v1/users -H 'Authorization: Bearer xxx' -d '{"name":"test"}'`, ensure status code is 201 and response contains 'id'"
67
+
68
+ The agent invokes `run_test_api`, validates against the expected contract, and returns structured pass/fail results.
69
+
70
+ ## Documentation
71
+
72
+ Full documentation is hosted on [GitLab Pages](https://ryaneatfood.gitlab.io/mcp-api-testing/) (or build locally with `mkdocs serve`).
73
+
74
+ - **[Getting Started](docs/getting-started/installation.md)**: installation and client setup
75
+ - **[Usage](docs/usage/request-modes.md)**: cURL mode, structured mode, assertions, response format
76
+ - **[Guides](docs/guides/troubleshooting.md)**: troubleshooting, development, configuration
77
+ - **[Reference](docs/reference/tool-parameters.md)**: full parameter reference
78
+
79
+ ## License
80
+
81
+ MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-api-test"
3
- version = "0.1.2"
3
+ version = "0.1.3"
4
4
  description = "MCP server for testing REST API with built-in assertions"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -42,4 +42,5 @@ package-dir = {"" = "src"}
42
42
  py-modules = ["server", "__main__", "logger", "models", "utils"]
43
43
 
44
44
  [project.optional-dependencies]
45
- dev = ["pytest", "pytest-asyncio", "respx"]
45
+ dev = ["pytest", "pytest-asyncio", "respx"]
46
+ docs = ["mkdocs-material"]
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-api-test
3
+ Version: 0.1.3
4
+ Summary: MCP server for testing REST API with built-in assertions
5
+ Author: Ryan Febriansyah
6
+ License-Expression: MIT
7
+ Keywords: testing,mcp,llm
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Natural Language :: English
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Quality Assurance
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp
22
+ Requires-Dist: httpx
23
+ Requires-Dist: python-dotenv
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Requires-Dist: pytest-asyncio; extra == "dev"
27
+ Requires-Dist: respx; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: mkdocs-material; extra == "docs"
30
+ Dynamic: license-file
31
+
32
+ # mcp-api-test
33
+
34
+ ![pipeline](https://gitlab.com/ryaneatfood/mcp-api-testing/badges/master/pipeline.svg)
35
+
36
+ An AI-native API testing engine that enables LLM agents to execute, validate, and reason about REST APIs using natural language or cURL inputs.
37
+
38
+ Unlike traditional testing frameworks, `mcp-api-test` exposes API testing as a **first-class capability for AI agents** rather than a developer-facing tool. LLM-powered clients invoke the `run_test_api` tool directly, making API validation a building block for autonomous coding agents, not a separate human-driven workflow.
39
+
40
+ It complements (rather than replaces) tools like pytest, Postman, and Playwright.
41
+
42
+ ## Use cases
43
+
44
+ - **QA & test engineering**: prompt an agent with natural language instead of crafting Postman requests
45
+ - **Post-deployment regression**: have an agent smoke-test critical paths after a deploy
46
+ - **Quick validation**: test an endpoint inline during a coding session
47
+ - **CI/CD automation**: agents validate deployments autonomously in pipelines
48
+
49
+ > **Token efficiency.** Agents get deterministic, structured results in a single tool call instead of parsing raw `curl` output. Fewer tokens, fewer hallucinations.
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install mcp-api-test
55
+ ```
56
+
57
+ Or from source:
58
+
59
+ ```bash
60
+ git clone git@gitlab.com:ryaneatfood/mcp-api-testing.git
61
+ cd mcp-api-testing
62
+ pip install -e .
63
+ ```
64
+
65
+ Requires Python >= 3.10.
66
+
67
+ ## Quick start
68
+
69
+ Configure your MCP client to use the server. For **OpenCode**, add to `opencode.json`:
70
+
71
+ ```json
72
+ {
73
+ "mcp": {
74
+ "mcp-api-test": {
75
+ "type": "local",
76
+ "command": ["mcp-api-test"],
77
+ "enabled": true
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ For **Claude Desktop**, add to `claude_desktop_config.json`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "mcp-api-test": {
89
+ "command": "mcp-api-test"
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ Then prompt your agent:
96
+
97
+ > "Test this API: `curl -X POST https://api.example.com/v1/users -H 'Authorization: Bearer xxx' -d '{"name":"test"}'`, ensure status code is 201 and response contains 'id'"
98
+
99
+ The agent invokes `run_test_api`, validates against the expected contract, and returns structured pass/fail results.
100
+
101
+ ## Documentation
102
+
103
+ Full documentation is hosted on [GitLab Pages](https://ryaneatfood.gitlab.io/mcp-api-testing/) (or build locally with `mkdocs serve`).
104
+
105
+ - **[Getting Started](docs/getting-started/installation.md)**: installation and client setup
106
+ - **[Usage](docs/usage/request-modes.md)**: cURL mode, structured mode, assertions, response format
107
+ - **[Guides](docs/guides/troubleshooting.md)**: troubleshooting, development, configuration
108
+ - **[Reference](docs/reference/tool-parameters.md)**: full parameter reference
109
+
110
+ ## License
111
+
112
+ MIT
@@ -6,3 +6,6 @@ python-dotenv
6
6
  pytest
7
7
  pytest-asyncio
8
8
  respx
9
+
10
+ [docs]
11
+ mkdocs-material
@@ -193,10 +193,15 @@ async def run_test_api(
193
193
  start_time = time.perf_counter()
194
194
  try:
195
195
  async with httpx.AsyncClient(timeout=30) as client:
196
- # prevent requests payload with None-type object or empty body
197
196
  kwargs = {"method": method, "url": full_path_url, "headers": headers}
198
197
  if payload is not None:
199
- kwargs["json"] = payload
198
+ # cURL parser may produce a raw string for non-JSON -d payloads
199
+ # (example: form-encoded data). Use content= to send as-is rather
200
+ # than json= which would double-encode the string.
201
+ if isinstance(payload, str):
202
+ kwargs["content"] = payload
203
+ else:
204
+ kwargs["json"] = payload
200
205
  response = await client.request(**kwargs)
201
206
  end_time = time.perf_counter()
202
207
  response_time_ms = (end_time - start_time) * 1000
@@ -245,9 +250,20 @@ async def run_test_api(
245
250
  if required_response_fields:
246
251
  for field in required_response_fields:
247
252
  if isinstance(resp_body, dict):
248
- # resolve conflict resolution about dot-nested structure
249
253
  is_exist = get_nested_fields(body=resp_body, field_path=field)
254
+ elif isinstance(resp_body, list):
255
+ # For JSON arrays, check whether at least one item
256
+ # (if dict) contains the expected field.
257
+ is_exist = any(
258
+ (
259
+ get_nested_fields(body=item, field_path=field)
260
+ if isinstance(item, dict)
261
+ else field in str(item)
262
+ )
263
+ for item in resp_body
264
+ )
250
265
  else:
266
+ # Scalar or plain-text response like substring match.
251
267
  is_exist = field in str(resp_body)
252
268
  assertions.append(
253
269
  {
@@ -283,9 +299,9 @@ async def run_test_api(
283
299
  )
284
300
  )
285
301
 
286
- overall_result = (
287
- all(a["passed"] for a in assertions) if assertions else response.is_success
288
- )
302
+ # When no assertions are provided there is nothing to check,
303
+ # set default to False so the user can see the raw response and decide.
304
+ overall_result = all(a["passed"] for a in assertions) if assertions else False
289
305
 
290
306
  result = APITestResult(
291
307
  api_name=api_name,
@@ -31,16 +31,19 @@ def render_console_template_result(result: APITestResult) -> str:
31
31
  lines.append("Assertions")
32
32
  lines.append(divider)
33
33
 
34
- for assertion in result.assertions:
35
- symbol = "✓" if assertion.passed else "x"
36
- lines.append(f"{symbol} {assertion.assertion}")
37
-
38
- lines.append("")
39
- lines.append("Summary")
40
- lines.append(divider)
41
- lines.append(f"Total Assertions : {len(result.assertions)}")
42
- lines.append(f"Passed : {passed_assertions}")
43
- lines.append(f"Failed : {failed_assertions}")
34
+ if result.assertions:
35
+ for assertion in result.assertions:
36
+ symbol = "✓" if assertion.passed else "x"
37
+ lines.append(f"{symbol} {assertion.assertion}")
38
+
39
+ lines.append("")
40
+ lines.append("Summary")
41
+ lines.append(divider)
42
+ lines.append(f"Total Assertions : {len(result.assertions)}")
43
+ lines.append(f"Passed : {passed_assertions}")
44
+ lines.append(f"Failed : {failed_assertions}")
45
+ else:
46
+ lines.append(" (no assertions provided)")
44
47
 
45
48
  return "\n".join(lines)
46
49