The open-source agent harness - the runtime layer that turns an LLM into a working agent.
feat: enhance getDbMcpConnection to support configured static headers for header-auth servers (#45)
Sujai Kumar Guptaa47d90095e9f
diff --git a/packages/server/src/runtime/dbSessionResources.ts b/packages/server/src/runtime/dbSessionResources.tsindex 5963b747a..f064aec2e 100644--- a/packages/server/src/runtime/dbSessionResources.ts+++ b/packages/server/src/runtime/dbSessionResources.ts@@ -14,6 +14,7 @@ import { HTTPException } from 'hono/http-exception';import type { IMcpServerStore, McpServerRecord } from '../db/mcpServerStore';import type { IModelProviderStore } from '../db/modelProviderStore';import type { ISkillStore } from '../db/skillStore';+import { resolveConfiguredMcpRequestHeaders } from '../schemas/mcpServer';export interface DbMcpConnection {url: string;@@ -104,7 +105,7 @@ function dcrHeadersResolver(params: {/*** Load MCP url + headers for a DB-configured server.- * DCR uses resolveMcpAuth; no-auth servers get empty static headers.+ * DCR uses resolveMcpAuth; header / no-auth use resolveConfiguredMcpRequestHeaders.* Throws HTTPException(400) if the server is not registered.*/export async function getDbMcpConnection({@@ -139,7 +140,7 @@ export async function getDbMcpConnection({}return {url: record.manifest.url,- headers: {},+ headers: resolveConfiguredMcpRequestHeaders(record.manifest),};}diff --git a/packages/server/tests/unit/runtime/getDbMcpConnection.test.ts b/packages/server/tests/unit/runtime/getDbMcpConnection.test.tsindex 641a56b8b..6b6577059 100644--- a/packages/server/tests/unit/runtime/getDbMcpConnection.test.ts+++ b/packages/server/tests/unit/runtime/getDbMcpConnection.test.ts@@ -161,4 +161,28 @@ describe('getDbMcpConnection', () => {expect(connection.url).toBe('https://mcp.open.example/mcp');expect(connection.headers).toEqual({});});++ it('returns configured static headers for header-auth servers', async () => {+ await mcpServerStore.upsertServer({+ tenant_id: TENANT_ID,+ name: 'header-mcp',+ manifest: {+ type: 'remote',+ name: 'header-mcp',+ url: 'https://mcp.header.example/mcp',+ auth: { type: 'header', headers: { Authorization: 'Bearer static-token' } },+ },+ });++ const connection = await getDbMcpConnection({+ tenant_id: TENANT_ID,+ name: 'header-mcp',+ store: mcpServerStore,+ tokenStore,+ clientName: 'test-client',+ });++ expect(connection.url).toBe('https://mcp.header.example/mcp');+ expect(connection.headers).toEqual({ Authorization: 'Bearer static-token' });+ });});