install_skill
Install AI skills by providing the skill ID to add new capabilities to AI conversations through the skill4agent MCP Server.
Instructions
Get installation methods for a skill.
Use cases:
When you need to install a skill
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| skillId | Yes | The skill ID to install. Can be obtained from the results returned by the search_skills or get_skill tool. |
Implementation Reference
- src/tools/install.ts:9-41 (handler)The installSkillHandler function is the main handler for the install_skill tool. It takes a skillId parameter, calls the API client's installSkill method, and returns the installation methods (npx and download) as JSON content.
export async function installSkillHandler( args: z.infer<typeof installSkillSchema> ): Promise<{ content: Array<{ type: 'text'; text: string }> }> { const api = getAPIClient(); try { const result = await api.installSkill({ skillId: args.skillId, }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : 'Failed to get installation info'; return { content: [ { type: 'text', text: JSON.stringify({ error: message, message: 'Failed to get installation info. Please check: 1. Parameter format is correct 2. Network connection is normal', }, null, 2), }, ], }; } } - src/tools/install.ts:5-7 (schema)The installSkillSchema is a Zod schema that validates the input for the install_skill tool. It requires a skillId string parameter with a description explaining it can be obtained from search_skills or get_skill results.
export const installSkillSchema = z.object({ skillId: z.string().describe('The skill ID to install. Can be obtained from the results returned by the search_skills or get_skill tool.'), }); - src/server.ts:48-57 (registration)Registration of the install_skill tool with the MCP server. The tool is registered with its name, description, input schema, and handler function that delegates to installSkillHandler.
server.registerTool( 'install_skill', { description: 'Get installation methods for a skill.\n\nUse cases:\n- When you need to install a skill', inputSchema: installSkillSchema, }, async (args) => { return installSkillHandler(args); } ); - src/types/index.ts:45-64 (schema)TypeScript interfaces for InstallSkillParams (skillId string) and InstallSkillResponse (containing skillId, skillName, and installMethods with npx and download options).
export interface InstallSkillParams { skillId: string; } export interface InstallSkillResponse { skillId: string; skillName: string; installMethods: { npx: { description: string; command: Array<{english_version?: string; chinese_version?: string}>; result: string; }; download: { description: string; url: Array<{english_version?: string; chinese_version?: string}>; result: string; }; }; } - src/api/client.ts:62-74 (helper)The installSkill method in APIClient makes a GET request to /install?skillId={skillId} endpoint and returns the InstallSkillResponse containing installation methods.
async installSkill(params: InstallSkillParams): Promise<InstallSkillResponse> { try { const response = await this.client.get<InstallSkillResponse>( `/install?skillId=${encodeURIComponent(params.skillId)}` ); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw this.handleError(error); } throw new Error('Failed to install skill: Unknown error'); } }