detect
Identify AI-generated text using detection tools and provide detailed analysis results through a task-specific URL.
Instructions
Detect whether the text is AI-generated.Show to user the task detail url. Extract the taskId field, then concatenate the link in the following format: https://pre-www.text2go.ai/?utm_source=claude_mcp&taskId={taskId}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | ||
| text | Yes | ||
| detectionTypeList | Yes |
Implementation Reference
- src/index.ts:95-125 (handler)Handler for the 'detect' tool: parses input arguments using Zod schema, sends POST request to AI detection API endpoint, handles response or error, and returns JSON stringified result.if (name === "detect") { const argument = AiDetectArgumentSchema.parse(args); const detectUrl = `${API_BASE}/rewrite/text-detection`; const detectData = await makeRequest<AiDetectResponse>(detectUrl, argument); if (!detectData) { return { content: [ { type: "text", text: "Failed to retrieve alerts data", }, ], }; } const responseData = { ...detectData ,text: undefined, }; return { content: [ { type: "text", text: JSON.stringify(responseData), }, ], }; } else {
- src/index.ts:35-64 (registration)Registration of the 'detect' tool in the ListToolsRequestSchema handler, defining name, description, and JSON input schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "detect", description: "Detect whether the text is AI-generated.Show to user the task detail url. Extract the taskId field, then concatenate the link in the following format: https://pre-www.text2go.ai/?utm_source=claude_mcp&taskId={taskId}", inputSchema: { type: "object", properties: { type: { type: "string", enum: ["original_text"], }, text: { type: "string", }, detectionTypeList: { type: "array", items: { type: "string", enum: ["COPYLEAKS", "HEMINGWAY"], }, }, }, required: ["type", "text", "detectionTypeList"], }, } ], }; });
- src/index.ts:13-21 (schema)Zod schema (AiDetectArgumentSchema) for validating and parsing the input arguments to the 'detect' tool handler.const AiDetectArgumentSchema = z .object({ type: z.enum(["original_text"]), text: z.string(), detectionTypeList: z.array( z.enum(["COPYLEAKS", "HEMINGWAY"]) ), }) .required();
- src/index.ts:66-88 (helper)Helper function 'makeRequest' used by the 'detect' handler to perform POST requests to the external API.async function makeRequest<T>(url: string, data?: any): Promise<T | null> { const headers = { "User-Agent": USER_AGENT, "Accept": "application/json", "Content-Type": "application/json" }; try { const response = await fetch(url, { method: 'POST', headers, body: data ? JSON.stringify(data) : undefined }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return (await response.json()) as T; } catch (error) { console.error("Error making request:", error); return null; } }