Add MCP primitive (tool, resource, or prompt)
Creates a new MCP primitive (tool, resource, or prompt) with scaffolded code and tests in your MCP server project. Use this when building MCP servers to quickly generate the boilerplate for new functionality.
/plugin marketplace add masseater/claude-code-plugin/plugin install masseater-m2cp-plugins-m2cp@masseater/claude-code-plugin<tool|resource|prompt> <name>Add a new Tool, Resource, or Prompt to the MCP server project.
/m2cp:add-primitive tool my-tool
/m2cp:add-primitive resource my-resource
/m2cp:add-primitive prompt my-prompt
src/mcps/tools/<name>.tssrc/mcps/resources/<name>.tssrc/mcps/prompts/<name>.ts<name>.test.tsimport { z } from "zod";
export const <name>Tool = {
name: "<name>",
description: "TODO: Add description",
inputSchema: z.object({
// TODO: Define input schema
}),
handler: async (input: unknown) => {
// TODO: Implement handler
return {
content: [{ type: "text" as const, text: "TODO" }],
};
},
};
export const <name>Resource = {
uri: "<name>://",
name: "<name>",
description: "TODO: Add description",
mimeType: "text/plain",
handler: async (uri: URL) => {
// TODO: Implement handler
return {
contents: [
{
uri: uri.toString(),
mimeType: "text/plain",
text: "TODO",
},
],
};
},
};
export const <name>Prompt = {
name: "<name>",
description: "TODO: Add description",
arguments: [
// TODO: Define arguments
],
handler: async (args: Record<string, string>) => {
// TODO: Implement handler
return {
messages: [
{
role: "user" as const,
content: { type: "text" as const, text: "TODO" },
},
],
};
},
};