A Model Context Protocol server that recommends and generates .gitignore files from the official github/gitignore repository.
This TypeScript-based MCP server provides:
- Recommendation tool:
recommend_gitignore— analyze a workspace and suggest matching templates. - Generation tool:
generate_gitignore— fetch templates and generate or write a combined.gitignore.
Key files
- Implementation:
src/index.ts - Compiled entrypoint:
build/index.js - Package manifest:
package.json
Install dependencies:
npm installBuild the server:
npm run buildFor development with auto-rebuild:
npm run watchYou can run the compiled server directly:
node build/index.jsOr use npx to run the package:
npx -y gitignore-recommenderWhen run, the server listens on stdio and exposes MCP tools such as recommend_gitignore and generate_gitignore.
Examples of how to invoke the tools (via an MCP-capable client):
- Recommend templates (inspect-only):
JSON call to tool
recommend_gitignorewith optional arguments:
{
"workspacePath": "d:/dev/projects/mcpservers",
"maxFiles": 20000
}- Generate a .gitignore by auto-detection and write to disk:
{
"workspacePath": "d:/dev/projects/mcpservers",
"topN": 1,
"writeToFile": true
}- Generate from explicit templates and return content (no write):
{
"workspacePath": "C:/path/to/project",
"templates": ["Node", "VisualStudioCode"],
"writeToFile": false
}To make this package runnable via npx you should:
-
Update
package.jsonwith repository, author and license metadata (already included in this repo). Seepackage.json. -
Ensure the
binfield points to the compiled entrypoint (this repo already has:"gitignore-recommender": "./build/index.js"). -
Build the package before publishing:
npm run build- Publish to npm (choose a package name that is available):
npm publish --access publicAfter publishing, users can run:
npx -y gitignore-recommenderor add it as the MCP server command in your MCP settings:
{
"mcpServers": {
"gitignore-recommender": {
"command": "npx",
"args": ["-y", "gitignore-recommender"]
}
}
}Notes and considerations
- Network access is required at runtime to fetch templates from raw.githubusercontent.com.
- The MCP server must have write permission to the target workspace if you plan to use
generate_gitignorewithwriteToFile: true. - Update the
repositoryfield inpackage.jsonto your GitHub repo before publishing so users can find the source.