{"id":26349589,"url":"https://github.com/willibrandon/netcontextserver","last_synced_at":"2025-03-16T09:18:53.812Z","repository":{"id":279396063,"uuid":"938670185","full_name":"willibrandon/NetContextServer","owner":"willibrandon","description":"A .NET implementation of the Model Context Protocol enabling AI assistants to explore and understand .NET codebases.","archived":false,"fork":false,"pushed_at":"2025-02-25T11:22:38.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T11:25:35.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willibrandon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-25T10:13:44.000Z","updated_at":"2025-02-25T11:22:42.000Z","dependencies_parsed_at":"2025-02-25T11:25:45.971Z","dependency_job_id":"fae496fa-5d0d-4f69-9200-426d7ea39f38","html_url":"https://github.com/willibrandon/NetContextServer","commit_stats":null,"previous_names":["willibrandon/netcontextserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2FNetContextServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2FNetContextServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2FNetContextServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willibrandon%2FNetContextServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willibrandon","download_url":"https://codeload.github.com/willibrandon/NetContextServer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847368,"owners_count":20357362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-16T09:18:53.261Z","updated_at":"2025-03-16T09:18:53.795Z","avatar_url":"https://github.com/willibrandon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetContextServer\n\nA .NET Codebase Context MCP Server that provides AI assistants with access to your .NET codebase through the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction). This allows AI tools to understand and work with your specific codebase context.\n\n## Features\n\n- 📁 **Project \u0026 File Listing**: List all projects and source files in your solution\n- 🔍 **Code Search**: Search through your codebase for specific patterns or text\n- 🧠 **Semantic Search**: Find code based on meaning, not just exact text matches\n- 📖 **File Content Access**: Read source files with safety checks and size limits\n- 🛡️ **Security**: Built-in safeguards for sensitive files and directory access\n- 🎯 **Pattern Management**: Flexible ignore patterns for controlling file access\n\n## Building from Source\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/willibrandon/NetContextServer.git\ncd NetContextServer\n```\n\n2. Build the solution:\n```bash\ndotnet build\n```\n\n3. Run the tests (optional):\n```bash\ndotnet test\n```\n\n## Running Commands\n\nUse the client to interact with your codebase:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- \u003ccommand\u003e [options]\n```\n\n### Environment Setup\n\nFor semantic search functionality, you need to set up the following environment variables:\n- `AZURE_OPENAI_ENDPOINT`: Your Azure OpenAI endpoint URL\n- `AZURE_OPENAI_API_KEY`: Your Azure OpenAI API key\n\n## Usage\n\n### Basic Commands\n\n1. **Set Base Directory**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory \"D:\\YourProject\"\n```\n\n2. **Get Base Directory**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- get-base-dir\n```\n\n3. **List Projects**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory \"D:\\YourProject\\src\"\n```\n\n4. **List Source Files**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- list-source-files --project-dir \"D:\\YourProject\\src\\YourProject\"\n```\n\n5. **Analyze Packages**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- analyze-packages\n```\n\n### Search Commands\n\n1. **Text Search**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- search-code --text \"authentication\"\n```\n\n2. **Semantic Search**:\n```bash\n# Search with default number of results (5)\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query \"handle user authentication\"\n\n# Search with custom number of results\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query \"database connection string\" --top 10\n```\n\nThe semantic search feature:\n- Uses embeddings to find code based on meaning\n- Returns code snippets ranked by relevance\n- Shows line numbers and similarity scores\n- Automatically indexes your code on first search\n\n### Pattern Management\n\n1. **Add Ignore Patterns**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns \"*.txt\" \"*.log\"\n```\n\n2. **View Current Patterns**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- get-ignore-patterns\n```\n\n3. **Remove Specific Patterns**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- remove-ignore-patterns --patterns \"*.txt\"\n```\n\n4. **Clear User Patterns**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- clear-ignore-patterns\n```\n\n5. **View State File Location**:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- get-state-file-location\n```\n\n### Default Ignore Patterns\n\nThe following patterns are ignored by default to protect sensitive information:\n- `*.env` - Environment files\n- `appsettings.*.json` - Application settings\n- `*.pfx` - Certificate files\n- `*.key` - Key files\n- `*.pem` - PEM files\n- `*password*` - Files containing \"password\" in the name\n- `*secret*` - Files containing \"secret\" in the name\n\n## Security Features\n\n1. **Path Safety**: Files can only be accessed within the specified base directory\n2. **Pattern Validation**: Ignore patterns are validated for proper syntax\n3. **Size Limits**: Large file contents are truncated to prevent memory issues\n4. **Sensitive File Protection**: Built-in patterns protect common sensitive files\n\n## Example Workflow\n\n1. Set the base directory for your project:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory \"D:\\Projects\\MyApp\"\n```\n\n2. Set up custom ignore patterns:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns \"*.generated.cs\" \"*.designer.cs\"\n```\n\n3. List all projects:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory \"D:\\Projects\\MyApp\\src\"\n```\n\n4. Search for authentication-related code:\n```bash\ndotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query \"user authentication and authorization logic\"\n```\n\n## Integration with AI Coding Tools\n\nNetContextServer implements the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), allowing seamless integration with AI coding assistants that support this protocol, such as:\n\n- **Cursor AI**: Provides your AI assistant with full context of your codebase for more accurate code generation and assistance\n- **Other MCP-compatible tools**: Any tool that implements the Model Context Protocol can connect to NetContextServer\n\nTo use with Cursor AI:\n1. Configure Cursor AI to use the NetContextServer as its MCP provider\n2. Enjoy enhanced code assistance with full codebase context\n\nThe Model Context Protocol enables AI tools to request specific information about your codebase, making the AI's suggestions more relevant and accurate to your specific project structure and coding patterns.\n\n## Error Handling\n\nThe server provides clear error messages for common scenarios:\n- Directory not found\n- Access denied (outside base directory)\n- Invalid patterns\n- File size limits exceeded\n- Restricted file types\n- Missing environment variables for semantic search\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n## Acknowledgments\n\n- Built with [MCPSharp](https://github.com/afrise/MCPSharp)\n- Uses Azure OpenAI for semantic embeddings\n- Inspired by the Model Context Protocol ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fnetcontextserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillibrandon%2Fnetcontextserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillibrandon%2Fnetcontextserver/lists"}