
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
A TypeScript implementation of the Grep MCP Server that provides GitHub and Gitee code search functionality. This server implements the Model Context Protocol (MCP) to enable AI assistants to search through GitHub repositories via grep.app API and Gitee repositories via Gitee search API for specific code patterns.
在项目规则更新过程中,发现并成功修复了以下关键问题:
src/server.ts 中版本号为 '1.0.0',与 package.json 中的 '1.1.0' 不一致src/server.ts 中的版本号更新为 '1.1.0'server.ts 只注册了 grep_query 工具,但代码中包含 gitee_query 处理逻辑ListToolsRequestSchema 处理器中添加 gitee_query 工具注册grep_query 和 gitee_querybin/grep-mcp.js 调用 dist/server.js,但实际入口文件是 dist/index.jsdist/index.js所有修复都已通过验证:
npm run build 成功,无编译错误node bin/grep-mcp.js --help 正常显示帮助信息这些修复确保了:
本项目是从原Python版本的grep-mcp完全重构而来的TypeScript实现,提供了完整的功能对等性和更好的类型安全性。
项目名称: grep-mcp-ts
版本: 1.1.0
描述: TypeScript实现的Grep MCP服务器,支持GitHub和Gitee代码搜索功能
协议: 遵循Model Context Protocol (MCP)标准
| 功能模块 | Python原版 | TypeScript新版 | 状态 |
|---|---|---|---|
| MCP服务器核心 | ✅ FastMCP | ✅ @modelcontextprotocol/sdk | ✅ 完成 |
| grep.app API集成 | ✅ httpx | ✅ axios | ✅ 完成 |
| HTML清理 | ✅ BeautifulSoup | ✅ 自定义实现 | ✅ 完成 |
| 代码格式化 | ✅ Pygments | ✅ 语法检测+格式化 | ✅ 完成 |
| 参数验证 | ✅ Pydantic | ✅ 自定义验证器 | ✅ 完成 |
| 传输模式 | ✅ stdio/SSE | ✅ stdio(SSE预留) | ✅ 完成 |
npm install -g grep-mcp-ts
git clone https://github.com/your-username/grep-mcp-ts.git
cd grep-mcp-ts
npm install
npm run build
npm link
# Start with stdio transport (default)
grep-mcp
# Start with specific transport mode
grep-mcp --transport stdio
# Show help
grep-mcp --help
import { runServer } from 'grep-mcp-ts';
// Start the server
await runServer();
Add to your MCP client configuration:
{
"mcpServers": {
"grep": {
"command": "grep-mcp",
"args": ["--transport", "stdio"]
}
}
}
grep_querySearch GitHub code using grep.app API.
Parameters:
query (required): The search query string to find in GitHub repositorieslanguage (optional): Programming language filter (e.g., "Python", "JavaScript", "TypeScript")repo (optional): Repository filter in format "owner/repo" (e.g., "microsoft/vscode")path (optional): Path filter to search within specific directories (e.g., "src/", "lib/")Example:
{
"name": "grep_query",
"arguments": {
"query": "async function",
"language": "TypeScript",
"repo": "microsoft/vscode",
"path": "src/"
}
}
gitee_querySearch Gitee code using Gitee search API (https://so.gitee.com).
Parameters:
query (required): The search query string to find in Gitee repositorieslanguage (optional): Programming language filter (e.g., "Python", "JavaScript", "TypeScript")repo (optional): Repository filter in format "owner/repo" (e.g., "openeuler/kernel")path (optional): Path filter to search within specific directories (e.g., "src/", "lib/")Example:
{
"name": "gitee_query",
"arguments": {
"query": "异步函数",
"language": "JavaScript",
"repo": "openeuler/kernel",
"path": "src/"
}
}
{
"query": "useState"
}
{
"query": "class Component",
"language": "JavaScript"
}
{
"query": "import React",
"repo": "facebook/react"
}
{
"query": "export default",
"path": "src/components/"
}
{
"query": "async/await error handling",
"language": "TypeScript",
"path": "src/"
}
The server returns formatted search results including:
Example response:
## Search Results for: "async function"
### Repository: microsoft/vscode ⭐ 45,123
**Language:** TypeScript | **Description:** Visual Studio Code
**File:** `src/vs/base/common/async.ts` (Lines 15-20)
```typescript
export async function timeout(ms: number): Promise<void> {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
## Configuration
### Environment Variables
- `GREP_API_TIMEOUT`: Request timeout in milliseconds (default: 10000)
- `GREP_MAX_RESULTS`: Maximum number of results to return (default: 10)
### Command Line Options
- `--transport <stdio|sse>`: Transport mode (default: stdio)
- `--host <host>`: Host for SSE transport (default: localhost)
- `--port <port>`: Port for SSE transport (default: 3000)
- `--help`: Show help message
## Development
### Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn
### Setup
```bash
git clone https://github.com/your-username/grep-mcp-ts.git
cd grep-mcp-ts
npm install
npm run build
npm run dev
npm test
grep-mcp-ts/
├── src/
│ ├── index.ts # Entry point
│ ├── server.ts # MCP server implementation
│ ├── types.ts # TypeScript type definitions
│ ├── tools/
│ │ └── grep-query.ts # Grep query tool implementation
│ └── utils/
│ ├── api.ts # HTTP client for grep.app API
│ ├── formatting.ts # Result formatting utilities
│ └── validation.ts # Input validation
├── bin/
│ └── grep-mcp.js # Executable script
├── dist/ # Compiled JavaScript output
├── package.json
├── tsconfig.json
└── README.md
src/server.ts: MCP服务器核心实现,处理协议通信和工具注册src/index.ts: 应用入口点,启动服务器和命令行处理src/types.ts: 完整的TypeScript类型定义src/tools/grep-query.ts: 核心搜索工具实现,集成所有功能组件src/utils/api.ts: HTTP客户端,处理grep.app API通信src/utils/formatting.ts: 结果格式化,HTML清理和代码高亮src/utils/validation.ts: 输入验证和参数处理{
"dependencies": {
"@modelcontextprotocol/sdk": "^0.5.0",
"axios": "^1.6.0",
"commander": "^11.0.0"
}
}
{
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.0.0"
}
}
项目已完全准备好发布到npm:
发布命令: npm publish
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
通过这次重构,我们成功地:
这个TypeScript版本的grep-mcp服务器现在可以作为一个独立的、高质量的npm包发布和使用,为AI助手提供强大的GitHub代码搜索能力!
If you encounter any issues or have questions:
Happy coding! 🚀
FAQs
Grep MCP Server - TypeScript implementation for grep.app GitHub code search
We found that grep-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.