mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-21 06:11:45 +00:00
test(mcp): add tests for OAuth 2.1, addon gating, and budget reorder
Covers OAuth integration flow, scope enforcement, addon-gated tool access, oauthService unit tests, and budget reorder/permission/reservation-sync scenarios.
This commit is contained in:
@@ -28,15 +28,19 @@ export interface McpHarnessOptions {
|
||||
withResources?: boolean;
|
||||
/** Register read-write tools (default: true) */
|
||||
withTools?: boolean;
|
||||
/** OAuth scopes to restrict tools; null = full access (default: null) */
|
||||
scopes?: string[] | null;
|
||||
/** Whether the session is authenticated via a static API token (default: false) */
|
||||
isStaticToken?: boolean;
|
||||
}
|
||||
|
||||
export async function createMcpHarness(options: McpHarnessOptions): Promise<McpHarness> {
|
||||
const { userId, withResources = true, withTools = true } = options;
|
||||
const { userId, withResources = true, withTools = true, scopes = null, isStaticToken = false } = options;
|
||||
|
||||
const server = new McpServer({ name: 'trek-test', version: '1.0.0' });
|
||||
|
||||
if (withResources) registerResources(server, userId);
|
||||
if (withTools) registerTools(server, userId);
|
||||
if (withTools) registerTools(server, userId, scopes ?? null, isStaticToken);
|
||||
|
||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user