mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-28 18:06:21 +02:00
MCP auth for the simple case (#557)
* MCP auth token header * Mention limitations * Fix AgentStep schema error by converting argument values to strings. * Added tests for MCP auth and agent step parsing
This commit is contained in:
parent
d9d4c91363
commit
4c3db4dbbe
8 changed files with 1361 additions and 56 deletions
|
|
@ -56,10 +56,16 @@ class Service(ToolService):
|
|||
else:
|
||||
remote_name = name
|
||||
|
||||
# Build headers with optional bearer token
|
||||
headers = {}
|
||||
if "auth-token" in self.mcp_services[name]:
|
||||
token = self.mcp_services[name]["auth-token"]
|
||||
headers["Authorization"] = f"Bearer {token}"
|
||||
|
||||
logger.info(f"Invoking {remote_name} at {url}")
|
||||
|
||||
# Connect to a streamable HTTP server
|
||||
async with streamablehttp_client(url) as (
|
||||
# Connect to a streamable HTTP server with headers
|
||||
async with streamablehttp_client(url, headers=headers) as (
|
||||
read_stream,
|
||||
write_stream,
|
||||
_,
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ class Processor(AgentService):
|
|||
AgentStep(
|
||||
thought=h.thought,
|
||||
action=h.name,
|
||||
arguments=h.arguments,
|
||||
arguments={k: str(v) for k, v in h.arguments.items()},
|
||||
observation=h.observation
|
||||
)
|
||||
for h in history
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue