Skip to content

Commit 688eb71

Browse files
authored
Merge pull request #7 from warpdev/feat/grep
Add find-tools for grep-like tool search
2 parents ec60ef2 + 29311fa commit 688eb71

8 files changed

Lines changed: 987 additions & 861 deletions

File tree

.releaserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"assets": [
1515
"package.json",
16-
"package-lock.json",
16+
"pnpm-lock.yaml",
1717
"CHANGELOG.md"
1818
],
1919
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"

CLAUDE.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is an MCP (Model Context Protocol) Hub server that acts as a proxy/aggregator for multiple MCP servers. It bypasses tool limitations in AI assistants (especially Cursor's 40-tool limit) and provides a unified interface to multiple MCP servers.
8+
9+
## Development Commands
10+
11+
### Build and Run
12+
```bash
13+
# Install dependencies
14+
pnpm install
15+
16+
# Build TypeScript to JavaScript
17+
pnpm build
18+
19+
# Run the server (after building)
20+
pnpm start
21+
22+
# Build and run in one command
23+
pnpm dev
24+
```
25+
26+
### Development Workflow
27+
```bash
28+
# For testing changes locally with npx
29+
npm link # Creates a global link to the local package
30+
npx mcp-hub-mcp # Test the linked version
31+
32+
# To unlink after testing
33+
npm unlink -g mcp-hub-mcp
34+
```
35+
36+
### Release Process
37+
- Uses semantic-release with Conventional Commits
38+
- Commits should follow: `type(scope): description`
39+
- Types: feat, fix, docs, style, refactor, perf, test, chore
40+
- Breaking changes: add `!` after type or `BREAKING CHANGE:` in body
41+
- Releases are automated via GitHub Actions on the main branch
42+
43+
## Architecture
44+
45+
### Core Components
46+
47+
1. **src/index.ts** - Entry point that creates the MCP server with three tools:
48+
- `list-all-tools`: Lists all available tools from connected servers
49+
- `call-tool`: Executes a tool on a specific server
50+
- `find-tools`: Grep-like search for tools matching regex patterns
51+
52+
2. **src/server-manager.ts** - `McpServerManager` class that:
53+
- Loads server configurations from JSON file
54+
- Manages connections to multiple MCP servers
55+
- Proxies tool calls to appropriate servers
56+
- Handles server lifecycle and error recovery
57+
- Implements `findTools` method for regex-based tool search
58+
59+
3. **src/types.ts** - Type definitions and Zod schemas for:
60+
- Server configuration validation
61+
- MCP SDK type exports
62+
- Configuration file structure
63+
- Parameter schemas for all tools
64+
65+
### Configuration
66+
67+
The server configuration is loaded from (in order of precedence):
68+
1. Environment variable: `MCP_CONFIG_PATH`
69+
2. Command-line argument: `--config-path`
70+
3. Default location: `./mcp-config.json` or `{cwd}/mcp-config.json`
71+
72+
Configuration format (Claude Desktop compatible):
73+
```json
74+
{
75+
"mcpServers": {
76+
"server-name": {
77+
"command": "command-to-run",
78+
"args": ["arg1", "arg2"],
79+
"env": { "KEY": "value" }
80+
}
81+
}
82+
}
83+
```
84+
85+
### Tool Naming Convention
86+
87+
Tools from connected servers are prefixed with the server name:
88+
- Original tool: `list-files`
89+
- Through hub: `server-name__list-files`
90+
91+
## Important Considerations
92+
93+
1. **Error Handling**: The hub gracefully handles server connection failures and continues operating with available servers.
94+
95+
2. **Environment Variables**: Server configurations can include environment variables that are passed to child processes.
96+
97+
3. **Logging**: Uses console.error for error messages since stdout is reserved for MCP protocol communication.
98+
99+
4. **No Tests**: Currently no test framework is set up. When implementing tests, consider:
100+
- Unit tests for server-manager.ts logic
101+
- Integration tests for MCP protocol handling
102+
- Mock MCP server responses for testing
103+
104+
5. **TypeScript Configuration**:
105+
- Target: ES2020
106+
- Module: NodeNext with NodeNext resolution
107+
- Strict mode enabled
108+
- Outputs to `dist/` directory
109+
- Declaration files generated
110+
111+
6. **Dependencies**:
112+
- Keep dependencies minimal (currently only @modelcontextprotocol/sdk and zod)
113+
- All types are exported from types.ts for consistency
114+
115+
7. **Binary Execution**: Configured as npm binary `mcp-hub-mcp` with shebang in index.ts

README.md

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ A hub server that connects to and manages other MCP (Model Context Protocol) ser
88

99
## Overview
1010

11-
This project builds an MCP hub server that can connect to other MCP servers, list their tools, and execute them.
12-
It is especially useful for bypassing Cursor’s 40-tool MCP limit.
13-
Even outside of Cursor, it helps reduce AI mistakes by hiding infrequently used tools.
11+
This project builds an MCP hub server that connects to and manages multiple MCP (Model Context Protocol) servers through a single interface.
12+
It helps prevent excessive context usage and pollution from infrequently used MCPs (e.g., Atlassian MCP, Playwright MCP) by allowing you to connect them only when needed.
13+
This reduces AI mistakes and improves performance by keeping the active tool set focused and manageable.
1414

1515
## Key Features
1616

@@ -40,13 +40,6 @@ Add this to your `mcp.json`:
4040
}
4141
```
4242

43-
### System Prompt (or Cursor Rules)
44-
45-
```
46-
Before processing a user's request, you must use the "list_all_tools" command to identify which tools are available.
47-
```
48-
49-
This ensures that the AI assistant will always check available tools before attempting to use them.
5043

5144
## Installation and Running
5245

@@ -185,6 +178,71 @@ Calls a tool on a specific server.
185178
}
186179
```
187180

181+
### 3. `find-tools`
182+
183+
Find tools matching a regex pattern across all connected servers (grep-like functionality).
184+
185+
- `pattern`: Regex pattern to search for in tool names and descriptions
186+
- `searchIn`: Where to search: "name", "description", or "both" (default: "both")
187+
- `caseSensitive`: Whether the search should be case-sensitive (default: false)
188+
189+
```json
190+
{
191+
"name": "find-tools",
192+
"arguments": {
193+
"pattern": "file",
194+
"searchIn": "both",
195+
"caseSensitive": false
196+
}
197+
}
198+
```
199+
200+
Example patterns:
201+
- `"file"` - Find all tools containing "file"
202+
- `"^read"` - Find all tools starting with "read"
203+
- `"(read|write).*file"` - Find tools for reading or writing files
204+
- `"config$"` - Find tools ending with "config"
205+
206+
Example output:
207+
```json
208+
{
209+
"filesystem": [
210+
{
211+
"name": "readFile",
212+
"description": "Read the contents of a file",
213+
"inputSchema": {
214+
"type": "object",
215+
"properties": {
216+
"path": {
217+
"type": "string",
218+
"description": "Path to the file to read"
219+
}
220+
},
221+
"required": ["path"]
222+
}
223+
},
224+
{
225+
"name": "writeFile",
226+
"description": "Write content to a file",
227+
"inputSchema": {
228+
"type": "object",
229+
"properties": {
230+
"path": {
231+
"type": "string",
232+
"description": "Path to the file to write"
233+
},
234+
"content": {
235+
"type": "string",
236+
"description": "Content to write to the file"
237+
}
238+
},
239+
"required": ["path", "content"]
240+
}
241+
}
242+
]
243+
}
244+
```
245+
188246
## Commit Message Convention
189247

190248
This project follows [Conventional Commits](https://www.conventionalcommits.org/) for automatic versioning and CHANGELOG generation.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
"author": "",
2626
"license": "MIT",
2727
"dependencies": {
28-
"@modelcontextprotocol/sdk": "^1.9.0",
29-
"zod": "^3.22.4"
28+
"@modelcontextprotocol/sdk": "^1.13.0",
29+
"zod": "^3.25.67"
3030
},
3131
"devDependencies": {
32-
"@types/node": "^18.19.3",
3332
"@semantic-release/changelog": "^6.0.3",
3433
"@semantic-release/git": "^10.0.1",
35-
"semantic-release": "^21.0.7",
36-
"typescript": "^5.3.3"
34+
"@types/node": "^22.15.32",
35+
"semantic-release": "^24.2.5",
36+
"typescript": "^5.8.3"
3737
}
3838
}

0 commit comments

Comments
 (0)