fix(mcp): sort imports and format MCP server
Biome reported unsorted imports and formatting issues in apps/api/src/index.ts and apps/api/src/mcp/server.ts. Auto-fixed via pnpm biome:fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,8 +7,8 @@ import { serve } from '@hono/node-server';
|
|||||||
import * as k8s from '@kubernetes/client-node';
|
import * as k8s from '@kubernetes/client-node';
|
||||||
import { createApp } from './app.js';
|
import { createApp } from './app.js';
|
||||||
import { loadConfig } from './config.js';
|
import { loadConfig } from './config.js';
|
||||||
import { connectTemporal, disconnectTemporal } from './services/temporal-client.js';
|
|
||||||
import { startMcpServer } from './mcp/server.js';
|
import { startMcpServer } from './mcp/server.js';
|
||||||
|
import { connectTemporal, disconnectTemporal } from './services/temporal-client.js';
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
// 1. Load configuration
|
// 1. Load configuration
|
||||||
|
|||||||
+14
-46
@@ -5,18 +5,12 @@
|
|||||||
|
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
import type * as k8s from '@kubernetes/client-node';
|
import type * as k8s from '@kubernetes/client-node';
|
||||||
import type { Client } from '@temporalio/client';
|
|
||||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||||
|
import type { Client } from '@temporalio/client';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import type { Config } from '../config.js';
|
import type { Config } from '../config.js';
|
||||||
import {
|
import { cancelScan, getReport, getScan, listScans, startScan } from '../services/scan-manager.js';
|
||||||
cancelScan,
|
|
||||||
getReport,
|
|
||||||
getScan,
|
|
||||||
listScans,
|
|
||||||
startScan,
|
|
||||||
} from '../services/scan-manager.js';
|
|
||||||
import type { CreateScanInput } from '../types/api.js';
|
import type { CreateScanInput } from '../types/api.js';
|
||||||
|
|
||||||
export interface McpServerDeps {
|
export interface McpServerDeps {
|
||||||
@@ -40,29 +34,21 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
server.registerTool(
|
server.registerTool(
|
||||||
'start_scan',
|
'start_scan',
|
||||||
{
|
{
|
||||||
description:
|
description: 'Start a new penetration test scan. Returns the scan ID and initial status.',
|
||||||
'Start a new penetration test scan. Returns the scan ID and initial status.',
|
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
targetUrl: z.string().describe('Target URL to scan (e.g., https://example.com)'),
|
targetUrl: z.string().describe('Target URL to scan (e.g., https://example.com)'),
|
||||||
gitUrl: z.string().describe(
|
gitUrl: z.string().describe('Git URL of the repository to analyze (e.g., https://github.com/user/repo)'),
|
||||||
'Git URL of the repository to analyze (e.g., https://github.com/user/repo)',
|
|
||||||
),
|
|
||||||
workspace: z
|
workspace: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.describe(
|
.describe(
|
||||||
'Optional workspace name. Must match /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/. Defaults to auto-generated from target URL.',
|
'Optional workspace name. Must match /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/. Defaults to auto-generated from target URL.',
|
||||||
),
|
),
|
||||||
gitRef: z
|
gitRef: z.string().optional().describe('Optional Git branch/tag/commit to checkout before scanning.'),
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.describe('Optional Git branch/tag/commit to checkout before scanning.'),
|
|
||||||
pipelineTesting: z
|
pipelineTesting: z
|
||||||
.boolean()
|
.boolean()
|
||||||
.optional()
|
.optional()
|
||||||
.describe(
|
.describe('If true, runs in minimal testing mode with fast retries (10s). Use for development.'),
|
||||||
'If true, runs in minimal testing mode with fast retries (10s). Use for development.',
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
async ({ targetUrl, gitUrl, workspace, gitRef, pipelineTesting }) => {
|
async ({ targetUrl, gitUrl, workspace, gitRef, pipelineTesting }) => {
|
||||||
@@ -91,12 +77,9 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
server.registerTool(
|
server.registerTool(
|
||||||
'get_scan',
|
'get_scan',
|
||||||
{
|
{
|
||||||
description:
|
description: 'Get the status, progress, and results of a running or completed scan.',
|
||||||
'Get the status, progress, and results of a running or completed scan.',
|
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
scanId: z.string().describe(
|
scanId: z.string().describe('The scan ID returned from start_scan (e.g., hightower-worker-abc123)'),
|
||||||
"The scan ID returned from start_scan (e.g., hightower-worker-abc123)",
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
async ({ scanId }) => {
|
async ({ scanId }) => {
|
||||||
@@ -104,9 +87,7 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [{ type: 'text' as const, text: `Scan '${scanId}' not found.` }],
|
||||||
{ type: 'text' as const, text: `Scan '${scanId}' not found.` },
|
|
||||||
],
|
|
||||||
isError: true,
|
isError: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -130,11 +111,7 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
inputSchema: z.object({}),
|
inputSchema: z.object({}),
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
const results = await listScans(
|
const results = await listScans(deps.config, deps.temporalClient, deps.batchApi);
|
||||||
deps.config,
|
|
||||||
deps.temporalClient,
|
|
||||||
deps.batchApi,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
@@ -151,19 +128,13 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
server.registerTool(
|
server.registerTool(
|
||||||
'cancel_scan',
|
'cancel_scan',
|
||||||
{
|
{
|
||||||
description:
|
description: 'Cancel a running scan by terminating its Kubernetes Job and Temporal workflow.',
|
||||||
'Cancel a running scan by terminating its Kubernetes Job and Temporal workflow.',
|
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
scanId: z.string().describe('The scan ID to cancel.'),
|
scanId: z.string().describe('The scan ID to cancel.'),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
async ({ scanId }) => {
|
async ({ scanId }) => {
|
||||||
await cancelScan(
|
await cancelScan(deps.config, deps.temporalClient, deps.batchApi, scanId);
|
||||||
deps.config,
|
|
||||||
deps.temporalClient,
|
|
||||||
deps.batchApi,
|
|
||||||
scanId,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
@@ -182,7 +153,7 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
{
|
{
|
||||||
description: 'Get the final security report for a completed scan.',
|
description: 'Get the final security report for a completed scan.',
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
scanId: z.string().describe("The scan ID to get the report for."),
|
scanId: z.string().describe('The scan ID to get the report for.'),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
async ({ scanId }) => {
|
async ({ scanId }) => {
|
||||||
@@ -209,10 +180,7 @@ function createMcpServer(deps: McpServerDeps): McpServer {
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startMcpServer(
|
export async function startMcpServer(deps: McpServerDeps, port: number): Promise<http.Server> {
|
||||||
deps: McpServerDeps,
|
|
||||||
port: number,
|
|
||||||
): Promise<http.Server> {
|
|
||||||
const mcpServer = createMcpServer(deps);
|
const mcpServer = createMcpServer(deps);
|
||||||
const transport = new StreamableHTTPServerTransport({
|
const transport = new StreamableHTTPServerTransport({
|
||||||
sessionIdGenerator: () => crypto.randomUUID(),
|
sessionIdGenerator: () => crypto.randomUUID(),
|
||||||
|
|||||||
Reference in New Issue
Block a user