foundry_dev_tools.config.palantir_mcp module#

Read the token cache maintained by Palantir MCP.

Palantir MCP stores Foundry tokens in ~/.palantir/mcp-config.json:

{
  "hosts": {
    "https://foundry.example.com": {
      "token": "eyJ..."
    }
  }
}

This module only reads that cache. Triggering the MCP re-authorization flow and changing the token scope is deliberately out of scope; re-authorize the token through your Palantir MCP client to refresh or expand its scope.

foundry_dev_tools.config.palantir_mcp.PALANTIR_MCP_CONFIG_FILE = 'mcp-config.json'#

The config file Palantir MCP writes, relative to the user’s home directory.

foundry_dev_tools.config.palantir_mcp.TOKEN_CLOCK_SKEW = 30#

Treat tokens that expire within this many seconds as already expired.

class foundry_dev_tools.config.palantir_mcp.PalantirMCPCredential[source]#

Bases: object

A host/token pair cached by Palantir MCP.

host: Host#
token: Token#
expires_at: float | None = None#
is_expired(now=None)[source]#

Return whether the token is expired (or expires within the clock skew).

Parameters:

now (float | None)

Return type:

bool

__init__(host, token, expires_at=None)#
Parameters:
  • host (Host)

  • token (Token)

  • expires_at (float | None)

Return type:

None

foundry_dev_tools.config.palantir_mcp.palantir_mcp_config_path()[source]#

Return the default Palantir MCP config path.

Return type:

Path

foundry_dev_tools.config.palantir_mcp.token_expiry(token)[source]#

Return the JWT exp claim as a Unix timestamp, if it can be decoded.

Parameters:

token (str)

Return type:

float | None

foundry_dev_tools.config.palantir_mcp.host_from_origin(origin)[source]#

Return the Host for an MCP origin like https://foundry.example.com.

A missing scheme defaults to HTTPS. Raises ValueError for anything that is not an HTTP(S) origin with a netloc.

Parameters:

origin (str)

Return type:

Host

foundry_dev_tools.config.palantir_mcp.read_palantir_mcp_credentials()[source]#

Read all usable host/token pairs from the Palantir MCP config.

A missing, unreadable, or malformed file is treated as an empty cache. Invalid host entries are skipped so that one bad entry cannot break the others.

Return type:

list[PalantirMCPCredential]

foundry_dev_tools.config.palantir_mcp.select_palantir_mcp_credential(credentials, host=None)[source]#

Select the credential for host, or the only unambiguous cached credential.

When host is provided, the matching entry is returned even if it is expired; PalantirMCPTokenProvider turns that into a clear error on first use.

When host is not provided, a single unexpired credential is used. If several hosts have unexpired tokens, the choice is ambiguous and a TokenProviderConfigError is raised instead of silently picking one.

Parameters:
Return type:

PalantirMCPCredential | None

foundry_dev_tools.config.palantir_mcp.discover_palantir_mcp_credential(host=None)[source]#

Return the automatically selectable Palantir MCP credential, if any.

When host is provided, only a credential cached for that exact origin is selected. Otherwise a single unambiguous unexpired credential is used.

Parameters:

host (Host | str | None)

Return type:

PalantirMCPCredential | None

foundry_dev_tools.config.palantir_mcp.print_auto_pickup_notice(credential)[source]#

Print one process-wide notice that the MCP credential was auto-detected.

Parameters:

credential (PalantirMCPCredential)

Return type:

None

foundry_dev_tools.config.palantir_mcp.reset_auto_pickup_notice()[source]#

Reset the one-time auto-pickup notice (used by tests).

Return type:

None