Creating MCP Tools

Creating MCP Tools

Project Structure

my-tool/
├── package.json      ← name, version, entry point
├── server.js         ← MCP server entry point
├── mcpm.json         ← client config (recommended)
└── README.md         ← documentation

mcpm.json — Client Configuration

The mcpm.json file maps directly to the mcpServers entry that users paste into their AI client config (Claude Desktop, Cursor, Windsurf, etc.):

<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;mcp&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;transport&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;stdio&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;command&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;node&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;args&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">&quot;server.js&quot;</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;env&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span><span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span>
Field Purpose
transport Almost always "stdio" for local servers
command How to run your server — node, python, uv, etc.
args Arguments for the command (e.g., ["server.js"])
env Environment variables like API keys

This is the exact structure that appears under mcpServers.<name> in claude_desktop_config.json and similar client config files. When users install your tool, this config is what they copy-paste.

Defining Tools

<span class="hljs-keyword">const</span> tools = [{
  <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;greet&quot;</span>,
  <span class="hljs-attr">description</span>: <span class="hljs-string">&quot;Greet someone&quot;</span>,
  <span class="hljs-attr">parameters</span>: { <span class="hljs-attr">name</span>: { <span class="hljs-attr">type</span>: <span class="hljs-string">&quot;string&quot;</span> } },
  <span class="hljs-attr">handler</span>: <span class="hljs-title function_">async</span> ({ name }) =&gt; ({ <span class="hljs-attr">message</span>: <span class="hljs-string">`Hello <span class="hljs-subst">${name}</span>!`</span> })
}];