Release v0.3.3
This commit is contained in:
+23
-1
@@ -140,11 +140,33 @@ class McpServer {
|
||||
|
||||
const requestHandler = async (request, response) => {
|
||||
try {
|
||||
if (request.method === 'GET' && request.url === '/health') {
|
||||
const requestUrl = new URL(request.url || '/', 'http://localhost');
|
||||
if (request.method === 'GET' && requestUrl.pathname === '/health') {
|
||||
this.log('info', 'GET /health');
|
||||
return json(response, 200, { ok: true, name: this.serverName, version: this.serverVersion }, this.negotiatedProtocolVersion);
|
||||
}
|
||||
|
||||
if (request.method === 'GET' && requestUrl.pathname === '/tools') {
|
||||
this.log('info', 'GET /tools');
|
||||
const includeCatalog = requestUrl.searchParams.get('catalog') === '1';
|
||||
const tools = includeCatalog && typeof this.toolRegistry.listToolCatalog === 'function'
|
||||
? this.toolRegistry.listToolCatalog()
|
||||
: this.toolRegistry.listTools();
|
||||
const baseUrl = `http://${request.headers.host || `${this.config.host}:${this.getPort()}`}`;
|
||||
return json(response, 200, {
|
||||
ok: true,
|
||||
name: this.serverName,
|
||||
version: this.serverVersion,
|
||||
count: tools.length,
|
||||
tools,
|
||||
examples: {
|
||||
health: `curl ${baseUrl}/health`,
|
||||
tools: `curl ${baseUrl}/tools`,
|
||||
catalog: `curl ${baseUrl}/tools?catalog=1`,
|
||||
},
|
||||
}, this.negotiatedProtocolVersion);
|
||||
}
|
||||
|
||||
if (!this.isAllowedOrigin(request)) {
|
||||
this.log('warn', `Rejected ${request.method} ${request.url}: invalid Origin header.`);
|
||||
return json(response, 403, { error: 'Forbidden: invalid Origin header' }, this.negotiatedProtocolVersion);
|
||||
|
||||
Reference in New Issue
Block a user