mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 03:01:02 +00:00
Merged via squash.
Prepared head SHA: 602b16a676
Co-authored-by: eleqtrizit <31522568+eleqtrizit@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
export type McpLoopbackRuntime = {
|
|
port: number;
|
|
token: string;
|
|
};
|
|
|
|
let activeRuntime: McpLoopbackRuntime | undefined;
|
|
|
|
export function getActiveMcpLoopbackRuntime(): McpLoopbackRuntime | undefined {
|
|
return activeRuntime ? { ...activeRuntime } : undefined;
|
|
}
|
|
|
|
export function setActiveMcpLoopbackRuntime(runtime: McpLoopbackRuntime): void {
|
|
activeRuntime = { ...runtime };
|
|
}
|
|
|
|
export function clearActiveMcpLoopbackRuntime(token: string): void {
|
|
if (activeRuntime?.token === token) {
|
|
activeRuntime = undefined;
|
|
}
|
|
}
|
|
|
|
export function createMcpLoopbackServerConfig(port: number) {
|
|
return {
|
|
mcpServers: {
|
|
openclaw: {
|
|
type: "http",
|
|
url: `http://127.0.0.1:${port}/mcp`,
|
|
headers: {
|
|
Authorization: "Bearer ${OPENCLAW_MCP_TOKEN}",
|
|
"x-session-key": "${OPENCLAW_MCP_SESSION_KEY}",
|
|
"x-openclaw-agent-id": "${OPENCLAW_MCP_AGENT_ID}",
|
|
"x-openclaw-account-id": "${OPENCLAW_MCP_ACCOUNT_ID}",
|
|
"x-openclaw-message-channel": "${OPENCLAW_MCP_MESSAGE_CHANNEL}",
|
|
"x-openclaw-sender-is-owner": "${OPENCLAW_MCP_SENDER_IS_OWNER}",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
}
|