Skip to content

Commit 28c08a2

Browse files
committed
Improved code and project quality
1 parent be41d85 commit 28c08a2

File tree

18 files changed

+6235
-601
lines changed

18 files changed

+6235
-601
lines changed

.eslintrc.cjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'eslint:recommended'
5+
],
6+
plugins: ['@typescript-eslint'],
7+
parserOptions: {
8+
ecmaVersion: 2022,
9+
sourceType: 'module'
10+
},
11+
env: {
12+
node: true,
13+
es2022: true
14+
},
15+
rules: {
16+
'no-unused-vars': 'off',
17+
'@typescript-eslint/no-unused-vars': 'error',
18+
'prefer-const': 'error',
19+
'no-var': 'error',
20+
'no-console': 'off'
21+
},
22+
ignorePatterns: [
23+
'build/',
24+
'dist/',
25+
'coverage/',
26+
'node_modules/',
27+
'*.js'
28+
]
29+
};

.github/copilot-instructions.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
2+
3+
This is an MCP (Model Context Protocol) server project that exposes curl functionality to MCP clients.
4+
5+
You can find more info and examples at https://modelcontextprotocol.io/llms-full.txt
6+
7+
## Project Guidelines
8+
9+
- This is a TypeScript project using ES modules
10+
- The MCP server uses stdio transport for communication with clients
11+
- All curl operations should be executed safely using the child_process.spawn method
12+
- Never use console.log() for debugging - use console.error() instead as stdout is reserved for MCP communication
13+
- The server exposes several tools for common HTTP operations: GET, POST, PUT, DELETE, file downloads, and advanced custom curl commands
14+
- Security is important: validate and sanitize all user inputs before passing to curl
15+
- The executeCurl helper function should be used for all curl operations to ensure consistency and safety

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x, 22.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run linter
31+
run: npm run lint:check
32+
33+
- name: Build project
34+
run: npm run build
35+
36+
- name: Test build artifact
37+
run: |
38+
chmod +x build/index.js
39+
timeout 5s node build/index.js || echo "Build artifact works (expected timeout)"
40+
41+
- name: Verify executable permissions
42+
run: test -x build/index.js
43+
44+
security:
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Setup Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20'
55+
cache: 'npm'
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Run security audit
61+
run: npm audit --audit-level=moderate
62+
63+
- name: Check for vulnerabilities
64+
run: npm audit --production

.gitignore

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ npm-debug.log*
44
yarn-debug.log*
55
yarn-error.log*
66
pnpm-debug.log*
7+
lerna-debug.log*
78

89
# Build artifacts
910
build/
1011
dist/
1112
out/
13+
lib/
1214
*.tsbuildinfo
13-
14-
# TypeScript cache
15-
*.tsbuildinfo
15+
*.js.map
16+
tsconfig.tsbuildinfo
1617

1718
# Runtime data
18-
pids
19+
pids/
1920
*.pid
2021
*.seed
2122
*.pid.lock
@@ -27,6 +28,9 @@ coverage/
2728
# nyc test coverage
2829
.nyc_output
2930

31+
# Jest cache
32+
.jest/
33+
3034
# Dependency directories
3135
jspm_packages/
3236

@@ -46,20 +50,24 @@ jspm_packages/
4650
.yarn-integrity
4751

4852
# dotenv environment variables file
49-
.env
50-
.env.local
51-
.env.development.local
52-
.env.test.local
53-
.env.production.local
53+
.env*
54+
!.env.example
5455

5556
# IDE and editor files
5657
.vscode/settings.json
5758
.vscode/launch.json
5859
.vscode/extensions.json
60+
.vscode/tasks.json
5961
.idea/
6062
*.swp
6163
*.swo
6264
*~
65+
.vim/
66+
67+
# JetBrains IDEs
68+
*.iml
69+
*.ipr
70+
*.iws
6371

6472
# OS generated files
6573
.DS_Store
@@ -69,43 +77,41 @@ jspm_packages/
6977
.Trashes
7078
ehthumbs.db
7179
Thumbs.db
80+
Desktop.ini
81+
82+
# Windows specific
83+
*.lnk
7284

7385
# Logs
74-
logs
86+
logs/
7587
*.log
7688

77-
# Runtime data
78-
pids
79-
*.pid
80-
*.seed
81-
*.pid.lock
82-
83-
# Optional npm cache directory
84-
.npm
85-
86-
# ESLint cache
87-
.eslintcache
88-
8989
# Microbundle cache
9090
.rpt2_cache/
9191
.rts2_cache_cjs/
9292
.rts2_cache_es/
9393
.rts2_cache_umd/
9494

95-
# Optional REPL history
96-
.node_repl_history
97-
98-
# Output of 'npm pack'
99-
*.tgz
100-
101-
# Yarn Integrity file
102-
.yarn-integrity
103-
10495
# Temporary folders
10596
tmp/
10697
temp/
98+
.tmp/
10799

108100
# MCP specific
109101
# Keep MCP configuration examples but ignore actual config
110102
**/mcp-config.json
111103
!examples/**/mcp-config.json
104+
105+
# Package manager lock files (keep package-lock.json for npm projects)
106+
# yarn.lock
107+
# pnpm-lock.yaml
108+
109+
# Compiled binary output
110+
*.exe
111+
*.out
112+
*.app
113+
114+
# Local environment and secrets
115+
secrets.json
116+
config.json
117+
!examples/config.json

.vscode/mcp.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"servers": {
3+
"curl-mcp": {
4+
"type": "stdio",
5+
"command": "npx",
6+
"args": ["curl-mcp"]
7+
}
8+
}
9+
}

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-07-26
9+
10+
### Added
11+
- Initial release of grep-mcp server
12+
- Natural language search intent tool (`grep_search_intent`)
13+
- Direct regex pattern search tool (`grep_regex`)
14+
- Match counting tool (`grep_count`)
15+
- File listing tool (`grep_files_with_matches`)
16+
- Advanced grep tool with custom arguments (`grep_advanced`)
17+
- Built-in patterns for common searches (emails, URLs, phone numbers, etc.)
18+
- Security-first design with input validation
19+
- Comprehensive documentation and examples
20+
- TypeScript support with full type safety
21+
- MCP (Model Context Protocol) compliance
22+
23+
### Security
24+
- Uses `spawn` with `shell: false` to prevent command injection
25+
- Input validation with Zod schemas
26+
- Path validation and sanitization
27+
- Blocked dangerous flags in advanced mode
28+
29+
### Documentation
30+
- Complete README with usage examples
31+
- API documentation for all tools
32+
- Security notes and best practices
33+
- Development setup instructions

CONTRIBUTING.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Contributing to grep-mcp
2+
3+
Thank you for your interest in contributing to grep-mcp! This document provides guidelines for contributing to the project.
4+
5+
## Getting Started
6+
7+
1. **Fork the repository** on GitHub
8+
2. **Clone your fork** locally:
9+
```bash
10+
git clone https://github.com/your-username/mcp-grep.git
11+
cd mcp-grep
12+
```
13+
3. **Install dependencies**:
14+
```bash
15+
npm install
16+
```
17+
4. **Build the project**:
18+
```bash
19+
npm run build
20+
```
21+
22+
## Development Workflow
23+
24+
1. **Create a feature branch**:
25+
```bash
26+
git checkout -b feature/your-feature-name
27+
```
28+
29+
2. **Make your changes** following our coding standards
30+
31+
3. **Build and test**:
32+
```bash
33+
npm run build
34+
npm test
35+
```
36+
37+
4. **Commit your changes**:
38+
```bash
39+
git commit -m "feat: add your feature description"
40+
```
41+
42+
5. **Push to your fork**:
43+
```bash
44+
git push origin feature/your-feature-name
45+
```
46+
47+
6. **Create a Pull Request** on GitHub
48+
49+
## Coding Standards
50+
51+
- **TypeScript**: Use TypeScript for all source code
52+
- **Code Style**: Follow the existing code style and formatting
53+
- **Error Handling**: Always handle errors appropriately
54+
- **Security**: Never introduce shell injection vulnerabilities
55+
- **Documentation**: Update README.md for new features
56+
- **Validation**: Use Zod schemas for input validation
57+
58+
## Commit Message Convention
59+
60+
We follow conventional commits:
61+
62+
- `feat:` - New features
63+
- `fix:` - Bug fixes
64+
- `docs:` - Documentation changes
65+
- `style:` - Code style changes (formatting, etc.)
66+
- `refactor:` - Code refactoring
67+
- `test:` - Adding or updating tests
68+
- `chore:` - Maintenance tasks
69+
70+
## Testing
71+
72+
- Write tests for new features
73+
- Ensure all existing tests pass
74+
- Test with actual MCP clients when possible
75+
- Include edge cases and error scenarios
76+
77+
## Security Considerations
78+
79+
When contributing:
80+
81+
- Never use `shell: true` in child_process.spawn
82+
- Always validate user input with Zod schemas
83+
- Sanitize file paths properly
84+
- Be cautious with regex patterns that could cause ReDoS
85+
86+
## Pull Request Guidelines
87+
88+
Before submitting a PR:
89+
90+
- ✅ Code builds without errors
91+
- ✅ All tests pass
92+
- ✅ Documentation is updated
93+
- ✅ Commit messages follow convention
94+
- ✅ No security vulnerabilities introduced
95+
- ✅ Code follows existing style
96+
97+
## Questions?
98+
99+
Feel free to open an issue for:
100+
- Bug reports
101+
- Feature requests
102+
- Questions about the codebase
103+
- Clarification on contributing guidelines
104+
105+
## License
106+
107+
By contributing to grep-mcp, you agree that your contributions will be licensed under the MIT License.

0 commit comments

Comments
 (0)