fix(litellm): sanitize customer ID in MCP server alias
LiteLLM rejects server names containing `-`, but customer IDs are UUIDs. Replace `-` with `_` in both the MCP server alias and key alias. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,8 +20,13 @@ interface LiteLLMMCPServerResponse {
|
|||||||
* so we create one MCP server entry per customer with the customer-specific
|
* so we create one MCP server entry per customer with the customer-specific
|
||||||
* demux URL. The virtual key is then scoped to only that server.
|
* demux URL. The virtual key is then scoped to only that server.
|
||||||
*/
|
*/
|
||||||
|
/** LiteLLM rejects server names containing `-`; replace with `_`. */
|
||||||
|
function toServerAlias(customerId: string): string {
|
||||||
|
return `sitebridge_${customerId.replace(/-/g, "_")}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function provisionMcpServer(customerId: string): Promise<string> {
|
export async function provisionMcpServer(customerId: string): Promise<string> {
|
||||||
const serverAlias = `sitebridge-${customerId}`;
|
const serverAlias = toServerAlias(customerId);
|
||||||
const demuxUrl = `${config.agilitonAccountUrl}/mcp/demux/${customerId}/mcp`;
|
const demuxUrl = `${config.agilitonAccountUrl}/mcp/demux/${customerId}/mcp`;
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
@@ -63,7 +68,7 @@ export async function provisionLiteLLMKey(customerId: string, email: string): Pr
|
|||||||
|
|
||||||
// 2. Create virtual key scoped to that MCP server
|
// 2. Create virtual key scoped to that MCP server
|
||||||
const body = {
|
const body = {
|
||||||
key_alias: `sb-${customerId}`,
|
key_alias: `sb_${customerId.replace(/-/g, "_")}`,
|
||||||
models: config.defaultModels,
|
models: config.defaultModels,
|
||||||
mcp_servers: [mcpServerAlias],
|
mcp_servers: [mcpServerAlias],
|
||||||
max_budget: config.defaultBudgetUsd,
|
max_budget: config.defaultBudgetUsd,
|
||||||
|
|||||||
Reference in New Issue
Block a user