Skip to main content
Glama

get_apifox_project_id_and_api_id_from_url

Extract Apifox project ID and API ID directly from a provided URL to enable integration and understanding of API details within Apifox projects.

Instructions

Get the project ID and API ID of Apifox from the URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to extract the project id and api id from

Implementation Reference

  • Handler function for the tool that extracts projectId and apiId from text using a helper and returns as JSON string.
    ({ text }) => { const { projectId, apiId } = extractProjectIdAndApiIdFromText(text) return { content: [ { type: "text", text: JSON.stringify({ projectId, apiId }), }, ], } },
  • Input schema defining the 'text' parameter as a string.
    { text: z .string() .describe("The text to extract the project id and api id from"), },
  • src/index.ts:13-33 (registration)
    Registers the MCP tool 'get_apifox_project_id_and_api_id_from_url' with description, input schema, and handler function.
    server.tool( "get_apifox_project_id_and_api_id_from_url", "Get the project ID and API ID of Apifox from the URL.", { text: z .string() .describe("The text to extract the project id and api id from"), }, ({ text }) => { const { projectId, apiId } = extractProjectIdAndApiIdFromText(text) return { content: [ { type: "text", text: JSON.stringify({ projectId, apiId }), }, ], } }, )
  • Supporting utility that implements the extraction logic using regex to find project ID and API ID from Apifox URLs or paths in the input text.
    export function extractProjectIdAndApiIdFromText(text: string) { const urlPattern = /apifox\.com\/link\/project\/(\d+)\/apis\/api-(\d+)/ const contentPattern = /project\/(\d+).*api-(\d+)/ let projectId = "" let apiId = "" // 寻找输入中的 URL 或相关内容 const lines = text.split("\n") for (const line of lines) { const trimmedLine = line.trim() // 尝试匹配完整 URL const urlMatch = trimmedLine.match(urlPattern) if (urlMatch) { projectId = urlMatch[1] apiId = urlMatch[2] break } // 尝试匹配部分路径 const contentMatch = trimmedLine.match(contentPattern) if (contentMatch) { projectId = contentMatch[1] apiId = contentMatch[2] break } } return { projectId, apiId } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sujianqingfeng/mcp-apifox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server