[scenario] OAuth basic & PRM variation (#11)
* readme for auth tests * wip prm test * add example helper for local oauth w/o browser * working through dangling timeout issue * add better test function * pretty printing * add mcp method * some more logging tweaks * refactor logger into 1 class * use common request logger * fix base scenario * some renaming * refactor into helpers * refactor to support second test * rm readme * add comment about www-authenticate
This commit is contained in:
parent
78d6bec42a
commit
69f02a4557
1 changed files with 1020 additions and 33 deletions
|
|
@ -5,8 +5,9 @@ import {
|
|||
ListToolsRequestSchema
|
||||
} from '@modelcontextprotocol/sdk/types.js';
|
||||
import type { Scenario, ConformanceCheck } from '../../types.js';
|
||||
import express, { Request, Response, NextFunction } from 'express';
|
||||
import express, { Request, Response } from 'express';
|
||||
import { ScenarioUrls } from '../../types.js';
|
||||
import { createRequestLogger } from '../request-logger.js';
|
||||
|
||||
function createServer(checks: ConformanceCheck[]): express.Application {
|
||||
const server = new Server(
|
||||
|
|
@ -86,33 +87,13 @@ function createServer(checks: ConformanceCheck[]): express.Application {
|
|||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
app.use((req: Request, res: Response, next: NextFunction) => {
|
||||
// Log incoming requests for debugging
|
||||
// console.log(`Incoming request: ${req.method} ${req.url}`);
|
||||
checks.push({
|
||||
id: 'incoming-request',
|
||||
name: 'IncomingRequest',
|
||||
description: `Received ${req.method} request for ${req.url}`,
|
||||
status: 'INFO',
|
||||
timestamp: new Date().toISOString(),
|
||||
details: {
|
||||
body: JSON.stringify(req.body)
|
||||
}
|
||||
});
|
||||
next();
|
||||
checks.push({
|
||||
id: 'outgoing-response',
|
||||
name: 'OutgoingResponse',
|
||||
// TODO: include MCP method?
|
||||
description: `Sent ${res.statusCode} response`,
|
||||
status: 'INFO',
|
||||
timestamp: new Date().toISOString(),
|
||||
details: {
|
||||
// TODO: Response body not available in express middleware
|
||||
statusCode: res.statusCode
|
||||
}
|
||||
});
|
||||
});
|
||||
app.use(
|
||||
createRequestLogger(checks, {
|
||||
incomingId: 'incoming-request',
|
||||
outgoingId: 'outgoing-response',
|
||||
mcpRoute: '/mcp'
|
||||
})
|
||||
);
|
||||
|
||||
app.post('/mcp', async (req: Request, res: Response) => {
|
||||
const transport = new StreamableHTTPServerTransport({
|
||||
|
|
|
|||
Loading…
Reference in a new issue