mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
docs: add comprehensive docstring for MCPProviderDataValidator
Adds inline documentation to help users understand: - How to structure provider_data in HTTP requests - Where to place mcp_headers vs mcp_authorization - Security requirements (no Authorization in headers) - Token format requirements (without Bearer prefix) - Example usage with multiple MCP endpoints
This commit is contained in:
parent
ccb870c8fb
commit
a2098eea27
1 changed files with 30 additions and 1 deletions
|
|
@ -10,9 +10,38 @@ from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class MCPProviderDataValidator(BaseModel):
|
class MCPProviderDataValidator(BaseModel):
|
||||||
# mcp_endpoint => dict of headers to send
|
"""
|
||||||
|
Validator for MCP provider-specific data passed via request headers.
|
||||||
|
|
||||||
|
This data structure is passed in the X-LlamaStack-Provider-Data header
|
||||||
|
to provide MCP endpoint-specific configuration.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
HTTP Request Headers:
|
||||||
|
X-LlamaStack-Provider-Data: {
|
||||||
|
"mcp_headers": {
|
||||||
|
"http://weather-mcp.com": {
|
||||||
|
"X-Trace-ID": "trace-123",
|
||||||
|
"X-Request-ID": "req-456"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mcp_authorization": {
|
||||||
|
"http://weather-mcp.com": "weather_api_token_xyz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Security Note:
|
||||||
|
- Authorization header MUST NOT be placed in mcp_headers
|
||||||
|
- Use the dedicated mcp_authorization field instead
|
||||||
|
- Each MCP endpoint can have its own separate token
|
||||||
|
- Tokens are provided WITHOUT the "Bearer " prefix (added automatically)
|
||||||
|
"""
|
||||||
|
|
||||||
|
# mcp_endpoint => dict of headers to send (excluding Authorization)
|
||||||
mcp_headers: dict[str, dict[str, str]] | None = None
|
mcp_headers: dict[str, dict[str, str]] | None = None
|
||||||
|
|
||||||
# mcp_endpoint => authorization token (without "Bearer " prefix)
|
# mcp_endpoint => authorization token (without "Bearer " prefix)
|
||||||
|
# Example: {"http://server.com": "token123"}
|
||||||
mcp_authorization: dict[str, str] | None = None
|
mcp_authorization: dict[str, str] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue