Hemang
1825f543a7
Remove unnecessary methods.
2025-06-12 14:07:11 +02:00
Hemang
9f564a0401
Refactor the LLM provider routes to move common functionalities into a BaseInstrumentedResponse class and move provier specific implementations in the corresponding BaseProvider implementations.
2025-06-12 14:07:11 +02:00
Hemang
42a9c1cc30
Readability changes.
2025-06-05 11:58:12 +02:00
Hemang
cd6d6a50b0
Small changes related to constants and sorting order of imports.
2025-06-05 10:17:34 +02:00
Hemang
7ec13ad852
Create StreamableTransport class for MCP Streamable http transport. This subclasses MCPTransportBase.
2025-06-04 11:46:35 +02:00
Hemang
7efd15e2a9
Move MCP related routes to the MCP directory and introduce the MCPTransportBase class.
2025-06-04 11:46:35 +02:00
Hemang
e8106776b4
Refactor stdio implementation to use McpSession class.
2025-06-04 11:46:35 +02:00
Hemang
6849fc7daa
Update McpSession class so that it can be used from both sse/streamable and stdio transports. Also update SseHeaderAttributes to McpAttributes so that it be can be used different MCP transports.
2025-06-04 11:46:35 +02:00
Hemang
bfb57029e6
Small cleanups.
2025-05-27 23:11:57 +02:00
Hemang
ab3fb98b67
Add blocking and logging related tests for MCP streamable HTTP route.
2025-05-27 23:11:57 +02:00
Hemang
34979ed18d
Move hook_tool_call and hook_tool_call_response to mcp_utils.py so that it can be used by both SSE and Streamable implementations.
2025-05-27 23:11:57 +02:00
Hemang
6e61a76168
Add blocking and logging of guardrails for MCP Streamable http route.
2025-05-27 23:11:57 +02:00
Hemang
20adc7804b
Accep the invariant api key in the header for sse gateway and use it for guardrailing and pushing to explorer.
2025-05-27 23:11:57 +02:00
Hemang
71e2ac9a06
Add implementation for MCP streamable GET, POST and DELETE endpoints without push to explorer or guardrailing.
2025-05-27 23:11:57 +02:00
Hemang
f8bf7be405
Add mcp_streamable route and refactor some common code between sse and streamable. Update tests for 400 errors in sse.
2025-05-27 23:11:57 +02:00
Hemang
5b68e80be5
Add MCP client and server name when calling fetch_guardrails_from_explorer in SSE.
2025-05-22 10:29:59 +02:00
Hemang
03817b005c
Update metadata in MCP SSE similar to what we do in MCP stdio.
2025-05-21 22:45:59 +02:00
Hemang
169eb066b9
Small cleanups in sse and stdio MCP implementation.
2025-05-21 15:58:22 +02:00
Luca Beurer-Kellner
e18c6b5bdb
Add an option to add extra metadata that is pushed and passed to Guardrails during an MCP session ( #47 )
...
* use select() before readline
* support for setting static metadata for MCP sessions
* nest extra mcp metadata in metadata object
* unify session metadata
* extra metadata tests
* use empty object as parameters, if None
* list_tools as tool call
* offset indices in tests
* test: adjust addresses
* mcp: make error reporting configurable
* line logging
* log version
* verbose logging + loud exception failure
* add server and client name to policy get
* append trace even if not pushing
* port tools/list message support to SSE
* use python -m build
* adjust guardrail failure address
* support for blocking tools/list in SSE
* use error-based failure response format by default
* tools/list test
* don't list_tools in stdio connect
* flaky test: handle second possible result in anthropic streaming case
---------
Co-authored-by: knielsen404 <kristian@invariantlabs.ai >
2025-05-19 13:44:37 +02:00
Hemang
edd9fd9a5c
When tool_call is blocked in MCP Post method, add the error message to a pending error messages list. Create two queues in the MCP SSE Get endpoint which correspond to the MCP server events and these pending error messages. These two queues are merged to return events back to the client.
2025-05-09 11:05:33 +05:30
Hemang
794aae0326
Add MCP guardrailing for SSE.
2025-05-08 20:40:28 +05:30
Hemang
40ec6d2db2
Add MCP SSE server proxying in gateway.
2025-05-08 14:11:22 +05:30
Hemang
2c34205c4c
Fix asyncio and threading. Dedupe annotations before pushing. Add README.
2025-04-17 07:15:28 +02:00
Hemang
66c6dcb8f9
Add mcp.py
2025-04-17 07:15:28 +02:00
Hemang
5bf121bbda
Use pyproject.toml instead of requirements.txt and fix some broken tests.
2025-04-17 07:15:28 +02:00
Luca Beurer-Kellner
c4dd3f3b19
Allow to specify different API keys for the guardrailing service ( #36 )
...
* minor refactor for getting invariant api keys for guardrailing
* allow different guardrailing api key
* tests
* fix comment + import
* improved unauthorized handling
2025-04-03 12:15:30 +02:00
Luca Beurer-Kellner
e17b53b927
Extract guardrails from header if provided ( #33 )
...
* guardrails from header
* use in-file guardrails in client.py
* support case without request
* remove client script
* tests: guardrailing rule passed in header
* include checked guardrails in annotation extra metadata
* include guardrailing action
* update guardrail metadata
2025-04-03 08:56:15 +02:00
Marco Milanta
37005c03be
fix: add tests (and found bug)
2025-04-02 16:03:51 +02:00
Marco Milanta
7b6d77e0a5
feat: add litellm support
2025-04-02 15:22:39 +02:00
Hemang
050ec1ba58
Fetch guardrails from explorer. These have higher precedence than than the guardrails from file.
2025-04-02 13:40:52 +02:00
Luca Beurer-Kellner
7c0bb957fb
Pipelined Guardrails ( #32 )
...
* initial draft: pipelined guardrails
* documentation on stream instrumentation
* more comments
* fix: return earlier
* non-streaming case
* handle non-streaming case
* fix more cases
* simplify request instrumentation
* improve comments
* fix import issues
* extend tests for input guardrailing
* anthropic integration of pipelined and pre-guardrailing
* fix gemini streamed refusal
2025-03-31 14:13:58 +02:00
Hemang
e55df73487
Add guardrails for gemini integration.
2025-03-27 12:26:17 +01:00
Hemang
a5ea86a64e
Show logs if the docker container doesn't start on doing up(). Tested when the guardrails file contained unparseable policy.
2025-03-17 07:45:45 +01:00
Hemang
e773cc9f2d
Add Guardrails verification logic for openai route.
2025-03-17 07:45:45 +01:00
Luca Beurer-Kellner
e40ea3e2a9
instructions + port configuration option
2025-03-11 17:38:41 +01:00
Hemang
20f8a12032
Formatting changes.
2025-03-10 15:18:13 +01:00
Hemang
e107be4fea
Add push to explorer support for Gemini for non streaming.
2025-03-10 15:18:13 +01:00
Hemang
7008f73310
Rename proxy to gateway.
2025-03-05 14:35:39 +01:00