mcp-server-modular
A modular MCP server that lets you add tools by dropping JavaScript files into a tools directory, with built-in shell command execution and safe execution options.
README
mcp-server-modular
No-code tool loading for MCP. Drop a .js file in the tools/ directory, restart the server, and your tool is live. No server code changes needed.
Quick Start
git clone https://github.com/itamos-technologia/mcp-server-modular.git
cd mcp-server-modular
npm install
node server.js
Server starts on http://localhost:3100/mcp. Connect any MCP client to this URL.
Creating a Tool
Create a .js file in tools/ that exports:
import { z } from 'zod';
export default {
name: 'my_tool',
description: 'What this tool does.',
schema: {
input: z.string().describe('The input parameter'),
verbose: z.boolean().optional().describe('Show extra detail'),
},
async handler({ input, verbose = false }, ctx) {
// Your logic here
// ctx.run(cmd) — execute shell command
// ctx.runSafe(bin, args) — execute without shell (no injection risk)
// ctx.esc(str) — escape string for shell
return {
content: [{ type: 'text', text: `Result: ${input}` }]
};
},
};
That's it. Restart the server and your tool is available to any MCP client.
Tool API
Every tool file must export an object with:
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Unique tool name |
description |
string |
No | Shown to the LLM |
schema |
object |
Yes | Zod schema for parameters |
handler |
async function |
Yes | Receives (args, ctx) |
Handler Context (ctx)
| Method | Description |
|---|---|
ctx.run(cmd, timeout?) |
Execute shell command (returns stdout) |
ctx.runSafe(bin, args, timeout?) |
Execute without shell — no injection possible |
ctx.esc(str) |
Escape string for safe shell interpolation |
Handler Return
Return an MCP content array:
return {
content: [
{ type: 'text', text: 'Your result here' }
]
};
Configuration
| Env Variable | Default | Description |
|---|---|---|
MCP_PORT |
3100 |
Server port |
Example Tools
tools/hello.js— Simple greeting (template for new tools)tools/run_command.js— Shell command execution
Architecture
server.js — MCP transport + tool discovery
tools/ — Drop tools here
hello.js — Example tool
run_command.js — Example tool
your_tool.js — Your custom tool
The server scans tools/ on startup, validates each file exports name, schema, and handler, and registers them with the MCP server. Schema validation is handled by Zod — invalid parameters are rejected before reaching your handler.
More from Itamos
mcp-server-modular is the free, open-source foundation.
MCP Basic — the full production toolkit built on top:
- 📄 Segment-based file editing — read and edit code at 5× token savings with built-in verification
- 🌐 Web page skeletonizer — browse any page at up to 89% token compression
- 📧 Universal mail client — IMAP/SMTP with auto-detect for Gmail, Outlook, Yahoo, and more
- 📋 Text offloader — large pastes compressed to skeleton references (34× savings)
- 🧠 Memory injection — semantic search across conversation history, injected automatically
- 📊 Token tracking dashboard — per-tool breakdown, lifetime savings, cost avoided
20M+ tokens saved and counting.
License
Apache 2.0 — see LICENSE
Author
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。