Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion infisical_sdk/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ class AgentVaultSessionAccessBundle(BaseModel):

@dataclass
class AgentVaultInlineService(BaseModel):
"""A service sent with an Agent Vault session, without its token, password or values. type is http, mcp, postgres, mysql or ssh, and the API returns only that type's fields: hostPattern, allowedMethods, allowedPathPrefixes, customHeaders and substitutions for http; serverUrl, transport, hostPattern and customHeaders for mcp; host, port, database and tls for postgres and mysql; host and port for ssh. Its nested settings, such as credential and tls, are left as the API returns them."""
"""A service sent with an Agent Vault session, without its token, password or values. type is http, mcp, postgres, mysql or ssh, and the API returns only that type's fields: hostPattern, allowedMethods, allowedPathPrefixes, customHeaders and substitutions for http; serverUrl, transport, hostPattern, allowedTools and customHeaders for mcp; host, port, database and tls for postgres and mysql; host and port for ssh. allowedTools is None when an MCP server allows every tool, or when the Infisical version doesn't return it. Its nested settings, such as credential and tls, are left as the API returns them."""
id: str
name: str
type: str
Expand All @@ -584,6 +584,7 @@ class AgentVaultInlineService(BaseModel):
port: Optional[int] = None
database: Optional[str] = None
tls: Optional[Dict[str, Any]] = None
allowedTools: Optional[List[str]] = None

@dataclass
class AgentVaultSession(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion infisical_sdk/resources/agent_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def create(
label: A short description of what the session is for, such as "nightly deploy". Up to 128 characters, without line breaks, tabs, or invisible characters.
on_behalf_of_user_email: The email address of the user to start the session on behalf of. Can't be combined with on_behalf_of_user_id.
on_behalf_of_user_id: The ID of the user to start the session on behalf of. Can't be combined with on_behalf_of_user_email.
services: Services the session carries itself, instead of or beside its access bundle's: up to 20 dicts with the API's field names, such as {"type": "http", "hostPattern": "api.github.com", "credential": {"type": "bearer", "value": token}}. Only Agent Vault admins can send them. Each has the same fields as a service in an access bundle, except that its name is optional for HTTP and MCP services (database and SSH services need one), its values can't use variables, it can't use OAuth or member-provided values, and an MCP server can't be limited to some of its tools. To limit an MCP server's tools, add it to an access bundle instead.
services: Services the session carries itself, instead of or beside its access bundle's: up to 20 dicts with the API's field names, such as {"type": "http", "hostPattern": "api.github.com", "credential": {"type": "bearer", "value": token}}. Only Agent Vault admins can send them. Each has the same fields as a service in an access bundle, except that its name is optional for HTTP and MCP services (database and SSH services need one), its values can't use variables, and it can't use OAuth or member-provided values. To limit an MCP server to some of its tools, send their names in allowedTools, which needs an Infisical version that accepts a tool list on a session's services.
project_id: The ID of the Agent Vault project to create the session in.

Returns:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_agent_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,26 @@ def test_sessions_read_an_inline_database_service(api, agent_vault, json_respons
assert service.description == "Orders replica"


def test_sessions_send_and_read_an_inline_mcp_servers_tool_list(api, agent_vault, json_response):
mcp_input = {
"type": "mcp", "name": "deepwiki", "serverUrl": "https://mcp.deepwiki.com/mcp", "transport": "streamable-http",
"credential": {"type": "bearer", "value": "mcp-token"}, "allowedTools": ["read_wiki_structure"],
}
mcp = {
"id": INLINE_SERVICE["id"], "name": "deepwiki", "description": None, "type": "mcp",
"serverUrl": "https://mcp.deepwiki.com/mcp", "transport": "streamable-http", "hostPattern": "mcp.deepwiki.com",
"allowedTools": ["read_wiki_structure"],
"credential": {"type": "bearer", "headerName": "Authorization", "headerPrefix": "Bearer"}, "customHeaders": [],
}
api.session.post.return_value = json_response({"session": dict(SESSION, token="token", services=[mcp])})
created = agent_vault.sessions.create(services=[mcp_input], project_id=PROJECT_ID)
assert api.session.post.call_args.kwargs["json"] == {"services": [mcp_input], "projectId": PROJECT_ID}
assert created.services[0].allowedTools == ["read_wiki_structure"]

api.session.get.return_value = json_response({"session": dict(SESSION, services=[dict(mcp, allowedTools=None)])})
assert agent_vault.sessions.get(SESSION["id"]).services[0].allowedTools is None


def test_access_bundles_list_grantees_reads_a_pending_organization_membership(api, agent_vault, json_response):
grantee = dict({key: ON_BEHALF_OF[key] for key in ("type", "id", "username", "email", "firstName", "lastName")},
isOrgMembershipPending=True, grantedAt="2026-10-27T00:00:00.000Z")
Expand Down
Loading