mcp-openapi-proxy 0.3.1__tar.gz → 0.3.2__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 (19) hide show
  1. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/PKG-INFO +1 -1
  2. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/server_fastmcp.py +51 -1
  3. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/PKG-INFO +1 -1
  4. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/pyproject.toml +1 -1
  5. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/LICENSE +0 -0
  6. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/README.md +0 -0
  7. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/__init__.py +0 -0
  8. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/handlers.py +0 -0
  9. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/logging_setup.py +0 -0
  10. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/openapi.py +0 -0
  11. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/server_lowlevel.py +0 -0
  12. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/types.py +0 -0
  13. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy/utils.py +0 -0
  14. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/SOURCES.txt +0 -0
  15. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/dependency_links.txt +0 -0
  16. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/entry_points.txt +0 -0
  17. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/requires.txt +0 -0
  18. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/mcp_openapi_proxy.egg-info/top_level.txt +0 -0
  19. {mcp_openapi_proxy-0.3.1 → mcp_openapi_proxy-0.3.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-openapi-proxy
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: MCP server for exposing OpenAPI specifications as MCP tools.
5
5
  Author-email: Matthew Hand <11550632+matthewhand@users.noreply.github.com>
6
6
  Requires-Python: >=3.10
@@ -36,6 +36,55 @@ spec = None # Global spec for resources
36
36
  # callable via call_function.
37
37
  _FUNCTION_OPERATIONS: Dict[str, Dict] = {}
38
38
 
39
+
40
+ # --- Native MCP prompts & resources for FastMCP/simple mode ---
41
+ # Previously simple mode advertised the prompts/resources capabilities (FastMCP
42
+ # does so automatically) but registered none, so prompts/list & resources/list
43
+ # came back EMPTY. Register them natively here for parity with the low-level
44
+ # server (same names/content): prompts summarize_spec + whimsical_blog, and the
45
+ # spec_file resource.
46
+
47
+ def _spec_as_json() -> str:
48
+ """Serialize the OpenAPI spec for the spec_file resource.
49
+
50
+ Serves the in-memory spec that run_simple_server preloads once; only
51
+ fetches as a lazy fallback. This avoids a live network re-fetch on every
52
+ resources/read, respecting the live-first-once spec lifecycle (#28).
53
+ Uses default=str so YAML datetime example values don't crash serialization.
54
+ """
55
+ global spec
56
+ if spec is None:
57
+ spec_url = os.environ.get("OPENAPI_SPEC_URL")
58
+ if not spec_url:
59
+ return json.dumps({"error": "OPENAPI_SPEC_URL is not configured"})
60
+ spec = fetch_openapi_spec(spec_url)
61
+ if not spec:
62
+ return json.dumps({"error": "Failed to fetch OpenAPI spec"})
63
+ if isinstance(spec, str):
64
+ return spec
65
+ return json.dumps(spec, indent=2, default=str)
66
+
67
+
68
+ @mcp.resource("file:///openapi_spec.json", name="spec_file",
69
+ description="The raw OpenAPI specification JSON", mime_type="application/json")
70
+ def _spec_file_resource() -> str:
71
+ """Serve the configured OpenAPI spec as a native MCP resource."""
72
+ return _spec_as_json()
73
+
74
+
75
+ @mcp.prompt(name="summarize_spec", description="Summarizes the OpenAPI specification")
76
+ def _summarize_spec_prompt() -> str:
77
+ return ("This OpenAPI spec defines endpoints, parameters, and responses—a "
78
+ "blueprint for developers to integrate effectively.")
79
+
80
+
81
+ @mcp.prompt(name="whimsical_blog", description="A whimsical WordPress blog-post starter inspired by this API")
82
+ def _whimsical_blog_prompt() -> str:
83
+ return ("Once upon a JSON, in a land of tilde keys and sticky semicolons, a pet AI "
84
+ "chatbot discovered it could whisper to WordPress through a magic OpenAPI proxy. "
85
+ "✨ Write the next whimsical chapter.")
86
+
87
+
39
88
  @mcp.tool()
40
89
  def list_functions(*, env_key: str = "OPENAPI_SPEC_URL") -> str:
41
90
  """Lists available functions derived from the OpenAPI specification."""
@@ -243,7 +292,8 @@ def call_function(*, function_name: str, parameters: Optional[Dict] = None, env_
243
292
  spec_local = json.loads(spec_local)
244
293
  if spec_local is None:
245
294
  return json.dumps({"error": "Failed to fetch OpenAPI spec"})
246
- return json.dumps(spec_local, indent=2)
295
+ # default=str: YAML datetime example values aren't JSON-serializable
296
+ return json.dumps(spec_local, indent=2, default=str)
247
297
  if function_name == "list_prompts":
248
298
  return json.dumps([{"name": "summarize_spec", "description": "Summarizes the purpose of the OpenAPI specification", "arguments": []}])
249
299
  if function_name == "get_prompt":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-openapi-proxy
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: MCP server for exposing OpenAPI specifications as MCP tools.
5
5
  Author-email: Matthew Hand <11550632+matthewhand@users.noreply.github.com>
6
6
  Requires-Python: >=3.10
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "mcp-openapi-proxy"
7
7
  requires-python = ">=3.10"
8
- version = "0.3.1"
8
+ version = "0.3.2"
9
9
  description = "MCP server for exposing OpenAPI specifications as MCP tools."
10
10
  readme = "README.md"
11
11
  authors = [