The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
doc: custom_auth object_permission usage for MCP access
Yuta Saito80f0a8474121
diff --git a/docs/my-website/docs/proxy/custom_auth.md b/docs/my-website/docs/proxy/custom_auth.mdindex 812b80d3e9c..3d46e1074cc 100644--- a/docs/my-website/docs/proxy/custom_auth.md+++ b/docs/my-website/docs/proxy/custom_auth.md@@ -9,6 +9,7 @@ You can now override the default api key auth.Make sure the response type follows the `UserAPIKeyAuth` pydantic object. This is used by for logging usage specific to that user key.```python+from fastapi import Requestfrom litellm.proxy._types import UserAPIKeyAuthasync def user_api_key_auth(request: Request, api_key: str) -> UserAPIKeyAuth:@@ -114,6 +115,29 @@ UserAPIKeyAuth()```+### Object Permission Example (MCP, agents, etc.)++```python+from litellm.proxy._experimental.mcp_server.mcp_server_manager import (+ global_mcp_server_manager,+)++def _server_id(name: str) -> str:+ server = global_mcp_server_manager.get_mcp_server_by_name(name)+ if not server:+ raise ValueError(f"Unknown MCP server '{name}'")+ return server.server_id++object_permission = LiteLLM_ObjectPermissionTable(+ mcp_servers=[_server_id("deepwiki"), _server_id("everything")], # MCP servers this key is allowed to use+ mcp_tool_permissions={"deepwiki": ["search", "read_doc"]}, # optional per-server tool allow-list+)++UserAPIKeyAuth(+ object_permission=object_permission,+)+```+### Advanced Configuration```pythonUserAPIKeyAuth(@@ -139,6 +163,7 @@ UserAPIKeyAuth(### Complete Example```python+from fastapi import Requestfrom datetime import datetime, timedeltafrom litellm.proxy._types import UserAPIKeyAuth, LitellmUserRoles@@ -333,4 +358,4 @@ async def user_api_key_auth(except Exception:raise Exception("Invalid API key")-```\ No newline at end of file+```