create_plugin_config
Generate custom plugin configurations for APISIX using the MCP server, enabling precise control over plugin settings, descriptions, and labels for API management.
Instructions
Create a new plugin config
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | plugin config ID | |
| plugins | Yes |
Implementation Reference
- src/tools/plugin.ts:38-40 (handler)Registration and inline handler for the 'create_plugin_config' tool. The handler performs a PUT request to the `/plugin_configs` endpoint using the `makeAdminAPIRequest` utility with the input arguments.server.tool("create_plugin_config", "Create a new plugin config", CreatePluginConfigSchema.shape, async (args) => { return await makeAdminAPIRequest(`/plugin_configs`, "PUT", args); });
- src/schemas/plugin.ts:44-47 (schema)Zod schema defining the input parameters for the create_plugin_config tool: an ID and plugins configuration.export const CreatePluginConfigSchema = z.object({ id: z.string().describe("plugin config ID"), plugins: PluginConfigSchema, });
- src/utils/adminAPI.ts:11-80 (helper)Helper utility that makes HTTP requests to the APISIX admin API using axios, returning formatted CallToolResult, used by the tool handler.export async function makeAdminAPIRequest( path: string, method: string = "GET", data?: object ): Promise<CallToolResult> { const baseUrl = `${APISIX_SERVER_HOST}:${APISIX_ADMIN_API_PORT}${APISIX_ADMIN_API_PREFIX}`; const url = `${baseUrl}${path}`; try { const response = await axios({ method, url, data, headers: { "X-API-KEY": APISIX_ADMIN_KEY, "Content-Type": "application/json", }, }); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { console.error(`Request failed: ${method} ${url}`); console.error( `Status: ${error.response?.status}, Error: ${error.message}` ); if (error.response?.data) { try { const stringifiedData = JSON.stringify(error.response.data); console.error(`Response data: ${stringifiedData}`); } catch { console.error(`Response data: [Cannot parse as JSON]`); } } return { isError: true, content: [ { type: "text", text: JSON.stringify( `Status: ${error.response?.status}\nMessage: ${error.message} Data:\n${JSON.stringify(error.response?.data || {}, null, 2)}`, null, 2 ), }, ], }; } else { return { isError: true, content: [ { type: "text", text: JSON.stringify(error, null, 2), }, ], }; } } }