Coverage for src/hush_hush/_generated/api/mcp/mcp.py: 0%
43 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT.
3from http import HTTPStatus
4from typing import Any
6import httpx
8from ... import errors
9from ...client import AuthenticatedClient, Client
10from ...models.error import Error
11from ...models.mcp_body import McpBody
12from ...models.mcp_response_200 import McpResponse200
13from ...types import Response
16def _get_kwargs(
17 *,
18 body: McpBody,
19) -> dict[str, Any]:
20 headers: dict[str, Any] = {}
22 _kwargs: dict[str, Any] = {
23 "method": "post",
24 "url": "/mcp",
25 }
27 _kwargs["json"] = body.to_dict()
29 headers["Content-Type"] = "application/json"
31 _kwargs["headers"] = headers
32 return _kwargs
35def _parse_response(
36 *, client: AuthenticatedClient | Client, response: httpx.Response
37) -> Error | McpResponse200 | None:
38 if response.status_code == 200:
39 response_200 = McpResponse200.from_dict(response.json())
41 return response_200
43 if response.status_code == 401:
44 response_401 = Error.from_dict(response.json())
46 return response_401
48 if response.status_code == 413:
49 response_413 = Error.from_dict(response.json())
51 return response_413
53 if client.raise_on_unexpected_status:
54 raise errors.UnexpectedStatus(response.status_code, response.content)
55 else:
56 return None
59def _build_response(
60 *, client: AuthenticatedClient | Client, response: httpx.Response
61) -> Response[Error | McpResponse200]:
62 return Response(
63 status_code=HTTPStatus(response.status_code),
64 content=response.content,
65 headers=response.headers,
66 parsed=_parse_response(client=client, response=response),
67 )
70def sync_detailed(
71 *,
72 client: AuthenticatedClient,
73 body: McpBody,
74) -> Response[Error | McpResponse200]:
75 """MCP (Model Context Protocol) endpoint
77 Serves the MCP Streamable HTTP transport - JSON-RPC 2.0 messages
78 exchanging tool calls with an MCP-capable client
79 (https://modelcontextprotocol.io). Exposes tools mirroring
80 hush-hush-cli's own operations: inject, get, update, delete, list,
81 edit, which changes an object's description, tags or slug without
82 its sealed value, used_by, which lists an object's consumers, and
83 list_consumers, add_consumer, update_consumer and delete_consumer
84 for the consumer directory, and audit_log, which queries the audit
85 log (docs/adr/0019-mcp-endpoint.md).
87 Gated the same way every other write route is, applied uniformly
88 across every tool - including get and list, which are
89 unauthenticated (get) or write-token-or-session-gated (list) over
90 their plain HTTP equivalents. One authenticated MCP session
91 performs every operation, rather than each tool reproducing
92 its HTTP twin's own auth shape.
94 The request and response bodies are MCP's own JSON-RPC 2.0
95 envelope, not described further here - OpenAPI can't usefully
96 express per-tool dynamic dispatch. The real per-tool contract is
97 the JSON Schema each tool's Go input/output type generates at
98 compile time, discoverable from a running server's own
99 `tools/list` call, not from this document.
101 Args:
102 body (McpBody): An MCP JSON-RPC 2.0 request.
104 Raises:
105 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106 httpx.TimeoutException: If the request takes longer than Client.timeout.
108 Returns:
109 Response[Error | McpResponse200]
110 """
112 kwargs = _get_kwargs(
113 body=body,
114 )
116 response = client.get_httpx_client().request(
117 **kwargs,
118 )
120 return _build_response(client=client, response=response)
123def sync(
124 *,
125 client: AuthenticatedClient,
126 body: McpBody,
127) -> Error | McpResponse200 | None:
128 """MCP (Model Context Protocol) endpoint
130 Serves the MCP Streamable HTTP transport - JSON-RPC 2.0 messages
131 exchanging tool calls with an MCP-capable client
132 (https://modelcontextprotocol.io). Exposes tools mirroring
133 hush-hush-cli's own operations: inject, get, update, delete, list,
134 edit, which changes an object's description, tags or slug without
135 its sealed value, used_by, which lists an object's consumers, and
136 list_consumers, add_consumer, update_consumer and delete_consumer
137 for the consumer directory, and audit_log, which queries the audit
138 log (docs/adr/0019-mcp-endpoint.md).
140 Gated the same way every other write route is, applied uniformly
141 across every tool - including get and list, which are
142 unauthenticated (get) or write-token-or-session-gated (list) over
143 their plain HTTP equivalents. One authenticated MCP session
144 performs every operation, rather than each tool reproducing
145 its HTTP twin's own auth shape.
147 The request and response bodies are MCP's own JSON-RPC 2.0
148 envelope, not described further here - OpenAPI can't usefully
149 express per-tool dynamic dispatch. The real per-tool contract is
150 the JSON Schema each tool's Go input/output type generates at
151 compile time, discoverable from a running server's own
152 `tools/list` call, not from this document.
154 Args:
155 body (McpBody): An MCP JSON-RPC 2.0 request.
157 Raises:
158 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
159 httpx.TimeoutException: If the request takes longer than Client.timeout.
161 Returns:
162 Error | McpResponse200
163 """
165 return sync_detailed(
166 client=client,
167 body=body,
168 ).parsed
171async def asyncio_detailed(
172 *,
173 client: AuthenticatedClient,
174 body: McpBody,
175) -> Response[Error | McpResponse200]:
176 """MCP (Model Context Protocol) endpoint
178 Serves the MCP Streamable HTTP transport - JSON-RPC 2.0 messages
179 exchanging tool calls with an MCP-capable client
180 (https://modelcontextprotocol.io). Exposes tools mirroring
181 hush-hush-cli's own operations: inject, get, update, delete, list,
182 edit, which changes an object's description, tags or slug without
183 its sealed value, used_by, which lists an object's consumers, and
184 list_consumers, add_consumer, update_consumer and delete_consumer
185 for the consumer directory, and audit_log, which queries the audit
186 log (docs/adr/0019-mcp-endpoint.md).
188 Gated the same way every other write route is, applied uniformly
189 across every tool - including get and list, which are
190 unauthenticated (get) or write-token-or-session-gated (list) over
191 their plain HTTP equivalents. One authenticated MCP session
192 performs every operation, rather than each tool reproducing
193 its HTTP twin's own auth shape.
195 The request and response bodies are MCP's own JSON-RPC 2.0
196 envelope, not described further here - OpenAPI can't usefully
197 express per-tool dynamic dispatch. The real per-tool contract is
198 the JSON Schema each tool's Go input/output type generates at
199 compile time, discoverable from a running server's own
200 `tools/list` call, not from this document.
202 Args:
203 body (McpBody): An MCP JSON-RPC 2.0 request.
205 Raises:
206 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
207 httpx.TimeoutException: If the request takes longer than Client.timeout.
209 Returns:
210 Response[Error | McpResponse200]
211 """
213 kwargs = _get_kwargs(
214 body=body,
215 )
217 response = await client.get_async_httpx_client().request(**kwargs)
219 return _build_response(client=client, response=response)
222async def asyncio(
223 *,
224 client: AuthenticatedClient,
225 body: McpBody,
226) -> Error | McpResponse200 | None:
227 """MCP (Model Context Protocol) endpoint
229 Serves the MCP Streamable HTTP transport - JSON-RPC 2.0 messages
230 exchanging tool calls with an MCP-capable client
231 (https://modelcontextprotocol.io). Exposes tools mirroring
232 hush-hush-cli's own operations: inject, get, update, delete, list,
233 edit, which changes an object's description, tags or slug without
234 its sealed value, used_by, which lists an object's consumers, and
235 list_consumers, add_consumer, update_consumer and delete_consumer
236 for the consumer directory, and audit_log, which queries the audit
237 log (docs/adr/0019-mcp-endpoint.md).
239 Gated the same way every other write route is, applied uniformly
240 across every tool - including get and list, which are
241 unauthenticated (get) or write-token-or-session-gated (list) over
242 their plain HTTP equivalents. One authenticated MCP session
243 performs every operation, rather than each tool reproducing
244 its HTTP twin's own auth shape.
246 The request and response bodies are MCP's own JSON-RPC 2.0
247 envelope, not described further here - OpenAPI can't usefully
248 express per-tool dynamic dispatch. The real per-tool contract is
249 the JSON Schema each tool's Go input/output type generates at
250 compile time, discoverable from a running server's own
251 `tools/list` call, not from this document.
253 Args:
254 body (McpBody): An MCP JSON-RPC 2.0 request.
256 Raises:
257 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
258 httpx.TimeoutException: If the request takes longer than Client.timeout.
260 Returns:
261 Error | McpResponse200
262 """
264 return (
265 await asyncio_detailed(
266 client=client,
267 body=body,
268 )
269 ).parsed