Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions packages/core/src/agents/agentLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,59 @@ Body`);
});
});

it('should convert mcp_servers with auth block in local agent (oauth with full fields)', () => {
const markdown = {
kind: 'local' as const,
name: 'oauth-test-agent',
description: 'An agent to test OAuth MCP with full fields',
mcp_servers: {
'test-server': {
url: 'https://api.example.com/mcp',
type: 'http' as const,
auth: {
type: 'oauth' as const,
client_id: 'my-client-id',
client_secret: 'my-client-secret',
scopes: ['read', 'write'],
authorization_url: 'https://auth.example.com/authorize',
token_url: 'https://auth.example.com/token',
issuer: 'https://auth.example.com',
audiences: ['audience1'],
redirect_uri: 'http://localhost:8080/callback',
token_param_name: 'access_token',
registration_url: 'https://auth.example.com/register',
},
timeout: 30000,
},
},
system_prompt: 'You are a test agent.',
};

const result = markdownToAgentDefinition(
markdown,
) as LocalAgentDefinition;
expect(result.kind).toBe('local');
expect(result.mcpServers).toBeDefined();
expect(result.mcpServers!['test-server']).toMatchObject({
url: 'https://api.example.com/mcp',
type: 'http',
oauth: {
enabled: true,
clientId: 'my-client-id',
clientSecret: 'my-client-secret',
scopes: ['read', 'write'],
authorizationUrl: 'https://auth.example.com/authorize',
tokenUrl: 'https://auth.example.com/token',
issuer: 'https://auth.example.com',
audiences: ['audience1'],
redirectUri: 'http://localhost:8080/callback',
tokenParamName: 'access_token',
registrationUrl: 'https://auth.example.com/register',
},
timeout: 30000,
});
});

it('should pass through unknown model names (e.g. auto)', () => {
const markdown = {
kind: 'local' as const,
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/agents/agentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const mcpServerSchema = z.object({
scopes: z.array(z.string()).optional(),
authorization_url: z.string().url().optional(),
token_url: z.string().url().optional(),
issuer: z.string().optional(),
Comment thread
abhipatel12 marked this conversation as resolved.
Outdated
audiences: z.array(z.string()).optional(),
redirect_uri: z.string().optional(),
token_param_name: z.string().optional(),
registration_url: z.string().optional(),
Comment thread
abhipatel12 marked this conversation as resolved.
Outdated
}),
])
.optional(),
Expand Down Expand Up @@ -552,6 +557,11 @@ export function markdownToAgentDefinition(
scopes: config.auth.scopes,
authorizationUrl: config.auth.authorization_url,
tokenUrl: config.auth.token_url,
issuer: config.auth.issuer,
audiences: config.auth.audiences,
redirectUri: config.auth.redirect_uri,
tokenParamName: config.auth.token_param_name,
registrationUrl: config.auth.registration_url,
};
}
}
Expand Down
Loading