Documentation
¶
Overview ¶
Package mcpsetup derives the hosted PromptVM MCP endpoint from the API base URL and writes/prints per-client MCP configuration (Claude Code, Codex CLI).
The snippet formats follow the frontend's src/lib/mcp/client-snippets.ts so every surface (web app, CLI, docs) shows equivalent configuration; header auth uses the MCP server's direct pk/sk bearer envelope (`Authorization: Bearer pvm_mcp_pkv1_<base64url(pk:sk)>`, see the frontend's src/lib/mcp/pksk-encoder.ts and the MCP contracts' PKSK_BEARER_PREFIX).
Index ¶
- Constants
- func ClaudeAddCommand(endpoint, scope string) []string
- func ClaudeMCPJSON(endpoint string) string
- func ClaudeSnippet(endpoint string) string
- func CodexSnippet(endpoint string, headers map[string]string) string
- func DeriveMCPURL(apiBaseURL string) string
- func ExistingCodexAuthorization(existing []byte) string
- func MergeCodexConfig(existing []byte, endpoint string, headers map[string]string) ([]byte, error)
- func PkSkAuthorization(publicKey, secretKey string) string
- func ResolveMCPURL(flagValue, apiBaseURL string) (string, error)
Constants ¶
const EnvMCPURL = "PROMPTVM_MCP_URL"
EnvMCPURL overrides the derived MCP endpoint.
const PKSKBearerPrefix = "pvm_mcp_pkv1_"
PKSKBearerPrefix is the MCP server's direct pk/sk bearer envelope prefix (cross-repo contract: mcp packages/contracts PKSK_BEARER_PREFIX, frontend src/lib/mcp/pksk-encoder.ts).
Variables ¶
This section is empty.
Functions ¶
func ClaudeAddCommand ¶
ClaudeAddCommand renders the Claude Code CLI registration command (format: client-snippets.ts `claude-code` OAuth snippet). scope is passed through explicitly — `claude mcp add` defaults to its private "local" scope, so omitting --scope for project installs would NOT register the shared, committed project scope the .mcp.json fallback writes.
func ClaudeMCPJSON ¶
ClaudeMCPJSON renders the project-level .mcp.json server entry used when the `claude` binary is not available (format: client-snippets.ts `generic-json`).
func ClaudeSnippet ¶
ClaudeSnippet is the copy-paste form of the Claude Code registration command.
func CodexSnippet ¶
CodexSnippet renders the ~/.codex/config.toml block (format: client-snippets.ts `codex-cli`). headers, when non-nil, are emitted as a `[mcp_servers.promptvm.headers]` table, matching the manual-token snippet shape.
func DeriveMCPURL ¶
DeriveMCPURL maps a PromptVM API base URL to its hosted MCP endpoint. The hosted server serves the streamable-HTTP protocol only at the /mcp path (everything else 404s), so the derived URL always carries it:
https://dev-api.promptvm.ai → https://dev-mcp.promptvm.ai/mcp https://staging-api.promptvm.ai → https://staging-mcp.promptvm.ai/mcp https://api.promptvm.ai → https://mcp.promptvm.ai/mcp
Returns "" when no mapping applies (e.g. localhost) so callers can require an explicit --mcp-url / PROMPTVM_MCP_URL (documented as the full endpoint, path included).
func ExistingCodexAuthorization ¶
ExistingCodexAuthorization returns the Authorization header of an existing [mcp_servers.promptvm.headers] table when it already carries a usable MCP pk/sk bearer ("Bearer pvm_mcp_pkv1_…"), or "" otherwise. Used to keep an already-working credential across re-runs instead of minting a new key.
func MergeCodexConfig ¶
MergeCodexConfig merges the promptvm MCP server entry into an existing ~/.codex/config.toml document (existing may be nil/empty for a fresh file). The merge is textual — comments, blank lines, key ordering, and formatting of all other content are preserved byte-for-byte. An existing [mcp_servers.promptvm] table (and its subtables) is removed and the fresh snippet is appended. headers, when non-nil, become [mcp_servers.promptvm.headers].
func PkSkAuthorization ¶
PkSkAuthorization packs an API key pair into the only header form the hosted MCP server authenticates: "Bearer pvm_mcp_pkv1_<base64url(pk:sk)>" (base64url, no padding — the server tolerates padding but the contract encoder omits it).
func ResolveMCPURL ¶
ResolveMCPURL resolves the MCP endpoint with the standard precedence: explicit flag value → PROMPTVM_MCP_URL env → derivation from the API base URL. Returns an error when nothing resolves.
Types ¶
This section is empty.