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

1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT. 

2 

3from http import HTTPStatus 

4from typing import Any 

5 

6import httpx 

7 

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 

14 

15 

16def _get_kwargs( 

17 *, 

18 body: McpBody, 

19) -> dict[str, Any]: 

20 headers: dict[str, Any] = {} 

21 

22 _kwargs: dict[str, Any] = { 

23 "method": "post", 

24 "url": "/mcp", 

25 } 

26 

27 _kwargs["json"] = body.to_dict() 

28 

29 headers["Content-Type"] = "application/json" 

30 

31 _kwargs["headers"] = headers 

32 return _kwargs 

33 

34 

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()) 

40 

41 return response_200 

42 

43 if response.status_code == 401: 

44 response_401 = Error.from_dict(response.json()) 

45 

46 return response_401 

47 

48 if response.status_code == 413: 

49 response_413 = Error.from_dict(response.json()) 

50 

51 return response_413 

52 

53 if client.raise_on_unexpected_status: 

54 raise errors.UnexpectedStatus(response.status_code, response.content) 

55 else: 

56 return None 

57 

58 

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 ) 

68 

69 

70def sync_detailed( 

71 *, 

72 client: AuthenticatedClient, 

73 body: McpBody, 

74) -> Response[Error | McpResponse200]: 

75 """MCP (Model Context Protocol) endpoint 

76 

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). 

86 

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. 

93 

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. 

100 

101 Args: 

102 body (McpBody): An MCP JSON-RPC 2.0 request. 

103 

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. 

107 

108 Returns: 

109 Response[Error | McpResponse200] 

110 """ 

111 

112 kwargs = _get_kwargs( 

113 body=body, 

114 ) 

115 

116 response = client.get_httpx_client().request( 

117 **kwargs, 

118 ) 

119 

120 return _build_response(client=client, response=response) 

121 

122 

123def sync( 

124 *, 

125 client: AuthenticatedClient, 

126 body: McpBody, 

127) -> Error | McpResponse200 | None: 

128 """MCP (Model Context Protocol) endpoint 

129 

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). 

139 

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. 

146 

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. 

153 

154 Args: 

155 body (McpBody): An MCP JSON-RPC 2.0 request. 

156 

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. 

160 

161 Returns: 

162 Error | McpResponse200 

163 """ 

164 

165 return sync_detailed( 

166 client=client, 

167 body=body, 

168 ).parsed 

169 

170 

171async def asyncio_detailed( 

172 *, 

173 client: AuthenticatedClient, 

174 body: McpBody, 

175) -> Response[Error | McpResponse200]: 

176 """MCP (Model Context Protocol) endpoint 

177 

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). 

187 

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. 

194 

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. 

201 

202 Args: 

203 body (McpBody): An MCP JSON-RPC 2.0 request. 

204 

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. 

208 

209 Returns: 

210 Response[Error | McpResponse200] 

211 """ 

212 

213 kwargs = _get_kwargs( 

214 body=body, 

215 ) 

216 

217 response = await client.get_async_httpx_client().request(**kwargs) 

218 

219 return _build_response(client=client, response=response) 

220 

221 

222async def asyncio( 

223 *, 

224 client: AuthenticatedClient, 

225 body: McpBody, 

226) -> Error | McpResponse200 | None: 

227 """MCP (Model Context Protocol) endpoint 

228 

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). 

238 

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. 

245 

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. 

252 

253 Args: 

254 body (McpBody): An MCP JSON-RPC 2.0 request. 

255 

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. 

259 

260 Returns: 

261 Error | McpResponse200 

262 """ 

263 

264 return ( 

265 await asyncio_detailed( 

266 client=client, 

267 body=body, 

268 ) 

269 ).parsed