style: auto-fix lint and format

This commit is contained in:
ajnart authored and github-actions[bot] committed 2026-06-08 21:39:41 +00:00
1 parent 7500128354
commit acf8d572da
5 files changed
+59 -31

No files matched your search

@@ -292,8 +292,12 @@ export function McpInstructions({ baseUrl, hasApiKeys, toolGroups }: McpInstruct
<AccordionItem key={group.namespace} value={group.namespace}> <AccordionItem key={group.namespace} value={group.namespace}>
<AccordionControl> <AccordionControl>
<Group gap="xs"> <Group gap="xs">
<Text size="sm" fw={600}>{group.namespace}</Text> <Text size="sm" fw={600}>
<Badge size="xs" variant="light" circle>{group.tools.length}</Badge> {group.namespace}
</Text>
<Badge size="xs" variant="light" circle>
{group.tools.length}
</Badge>
</Group> </Group>
</AccordionControl> </AccordionControl>
<AccordionPanel> <AccordionPanel>
@@ -304,8 +308,12 @@ export function McpInstructions({ baseUrl, hasApiKeys, toolGroups }: McpInstruct
{toolTypeDisplay[tool.type].method} {toolTypeDisplay[tool.type].method}
</Badge> </Badge>
<div> <div>
<Code fz="xs" fw={600}>{tool.name}</Code> <Code fz="xs" fw={600}>
<Text size="xs" c="dimmed" lh={1.4}>{tool.description}</Text> {tool.name}
</Code>
<Text size="xs" c="dimmed" lh={1.4}>
{tool.description}
</Text>
</div> </div>
</div> </div>
))} ))}
@@ -29,10 +29,12 @@ declare global {
var mcpRateLimit: RateLimitStore | undefined; var mcpRateLimit: RateLimitStore | undefined;
} }
const rateLimitStore = globalThis.mcpRateLimit ?? (globalThis.mcpRateLimit = { const rateLimitStore =
authFailures: new Map(), globalThis.mcpRateLimit ??
cleanupTimer: null, (globalThis.mcpRateLimit = {
}); authFailures: new Map(),
cleanupTimer: null,
});
const authFailures = rateLimitStore.authFailures; const authFailures = rateLimitStore.authFailures;
if (!rateLimitStore.cleanupTimer) { if (!rateLimitStore.cleanupTimer) {
@@ -203,7 +205,10 @@ const mcpHandler = createMcpHandler(
}; };
} catch (error) { } catch (error) {
const message = sanitizeErrorMessage(error); const message = sanitizeErrorMessage(error);
logger.warn("MCP tool execution failed", { tool: name, error: error instanceof Error ? error.message : String(error) }); logger.warn("MCP tool execution failed", {
tool: name,
error: error instanceof Error ? error.message : String(error),
});
return { return {
content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }], content: [{ type: "text" as const, text: JSON.stringify({ error: message }) }],
isError: true, isError: true,
@@ -248,7 +253,11 @@ const handler = async (req: NextRequest) => {
const { ua } = userAgent(req); const { ua } = userAgent(req);
if (!checkAuthRateLimit(ipAddress)) { if (!checkAuthRateLimit(ipAddress)) {
return jsonErrorResponse(429, { error: "rate_limited", hint: "Too many failed authentication attempts. Try again later." }, { "Retry-After": "60" }); return jsonErrorResponse(
429,
{ error: "rate_limited", hint: "Too many failed authentication attempts. Try again later." },
{ "Retry-After": "60" },
);
} }
if (!apiKeyValue) { if (!apiKeyValue) {
@@ -256,7 +265,10 @@ const handler = async (req: NextRequest) => {
const baseUrl = extractBaseUrlFromHeaders(req.headers); const baseUrl = extractBaseUrlFromHeaders(req.headers);
return jsonErrorResponse( return jsonErrorResponse(
401, 401,
{ error: "unauthorized", hint: "Authenticate with an ApiKey header or via OAuth at /.well-known/oauth-authorization-server" }, {
error: "unauthorized",
hint: "Authenticate with an ApiKey header or via OAuth at /.well-known/oauth-authorization-server",
},
{ "WWW-Authenticate": `Bearer resource_metadata="${baseUrl}/.well-known/oauth-protected-resource"` }, { "WWW-Authenticate": `Bearer resource_metadata="${baseUrl}/.well-known/oauth-protected-resource"` },
); );
} }
@@ -270,7 +282,10 @@ const handler = async (req: NextRequest) => {
if (!session) { if (!session) {
recordAuthFailure(ipAddress); recordAuthFailure(ipAddress);
return jsonErrorResponse(401, { error: "invalid_token", hint: "The API key was not found or the token is incorrect." }); return jsonErrorResponse(401, {
error: "invalid_token",
hint: "The API key was not found or the token is incorrect.",
});
} }
clearAuthFailures(ipAddress); clearAuthFailures(ipAddress);
+8 -6
View File
@@ -38,12 +38,14 @@ declare global {
var mcpOAuthStore: OAuthStore | undefined; var mcpOAuthStore: OAuthStore | undefined;
} }
const store = globalThis.mcpOAuthStore ?? (globalThis.mcpOAuthStore = { const store =
clients: new Map(), globalThis.mcpOAuthStore ??
authCodes: new Map(), (globalThis.mcpOAuthStore = {
pendingAuths: new Map(), clients: new Map(),
cleanupTimer: null, authCodes: new Map(),
}); pendingAuths: new Map(),
cleanupTimer: null,
});
const clients = store.clients; const clients = store.clients;
const authCodes = store.authCodes; const authCodes = store.authCodes;
const pendingAuths = store.pendingAuths; const pendingAuths = store.pendingAuths;
@@ -12,10 +12,12 @@ declare global {
var mcpRegisterRateLimit: RateLimitStore | undefined; var mcpRegisterRateLimit: RateLimitStore | undefined;
} }
const store = globalThis.mcpRegisterRateLimit ?? (globalThis.mcpRegisterRateLimit = { const store =
attempts: new Map(), globalThis.mcpRegisterRateLimit ??
timer: null, (globalThis.mcpRegisterRateLimit = {
}); attempts: new Map(),
timer: null,
});
const registerAttempts = store.attempts; const registerAttempts = store.attempts;
if (!store.timer) { if (!store.timer) {
@@ -22,10 +22,12 @@ declare global {
var mcpTokenRateLimit: RateLimitStore | undefined; var mcpTokenRateLimit: RateLimitStore | undefined;
} }
const store = globalThis.mcpTokenRateLimit ?? (globalThis.mcpTokenRateLimit = { const store =
failures: new Map(), globalThis.mcpTokenRateLimit ??
timer: null, (globalThis.mcpTokenRateLimit = {
}); failures: new Map(),
timer: null,
});
const tokenFailures = store.failures; const tokenFailures = store.failures;
if (!store.timer) { if (!store.timer) {
@@ -133,10 +135,9 @@ export async function POST(req: Request) {
scope: "mcp:tools", scope: "mcp:tools",
}); });
} catch (error) { } catch (error) {
logger.error("Failed to create API key during OAuth token exchange", { error: error instanceof Error ? error.message : String(error) }); logger.error("Failed to create API key during OAuth token exchange", {
return Response.json( error: error instanceof Error ? error.message : String(error),
{ error: "server_error", error_description: "Failed to issue access token" }, });
{ status: 500 }, return Response.json({ error: "server_error", error_description: "Failed to issue access token" }, { status: 500 });
);
} }
} }