Commit Graph

8 Commits

Author SHA1 Message Date
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
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 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
Hemang 050ec1ba58 Fetch guardrails from explorer. These have higher precedence than than the guardrails from file. 2025-04-02 13:40:52 +02:00