Skip to main content
Glama

DotNet MCP Server Demo

by kasirajan22
MCP_CONFIGURATION.md5.05 kB
# MCP Configuration Guide This directory contains various MCP (Model Context Protocol) configuration files that allow different clients to connect to your .NET MCP server. ## Files Overview - **`mcp.json`** - Basic MCP server configuration - **`mcp-settings.json`** - VS Code specific MCP settings - **`claude_desktop_config.json`** - Claude Desktop MCP configuration - **`mcp-bridge.js`** - Node.js bridge for stdio-based MCP clients - **`.vscode/settings.json`** - VS Code workspace settings for GitHub Copilot MCP - **`package.json`** - Node.js package configuration for the bridge ## Setup Instructions ### Prerequisites 1. **Node.js** (version 14+) - Required for the MCP bridge 2. **.NET 8 SDK** - Required to run the MCP server 3. **VS Code with GitHub Copilot** - For VS Code integration ### Step 1: Start the .NET MCP Server ```powershell # Navigate to the project directory cd "d:\DotNet\MCPDemo" # Start the server dotnet run ``` The server will start on `http://localhost:5000` ### Step 2: Configure Your MCP Client #### For VS Code with GitHub Copilot 1. Copy the contents of `.vscode/settings.json` to your VS Code workspace settings 2. Or add this to your global VS Code settings: ```json { "github.copilot.mcp.servers": { "mcp-demo": { "name": "MCP Demo Server", "description": "Local .NET MCP server with tools for time, echo, and calculations", "command": "node", "args": ["mcp-bridge.js"], "cwd": "d:\\DotNet\\MCPDemo", "env": { "MCP_SERVER_URL": "http://localhost:5000", "MCP_USERNAME": "admin", "MCP_PASSWORD": "password123" } } } } ``` #### For Claude Desktop 1. Locate your Claude Desktop configuration file: - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Linux**: `~/.config/Claude/claude_desktop_config.json` 2. Add the server configuration from `claude_desktop_config.json` to your Claude config: ```json { "mcpServers": { "mcp-demo": { "command": "node", "args": ["mcp-bridge.js"], "cwd": "d:\\DotNet\\MCPDemo", "env": { "MCP_SERVER_URL": "http://localhost:5000", "MCP_USERNAME": "admin", "MCP_PASSWORD": "password123" } } } } ``` ### Step 3: Test the Connection #### Test with VS Code 1. Open VS Code in the project directory 2. Start GitHub Copilot Chat 3. Ask Copilot to use the MCP tools: "What time is it?" or "Calculate 15 + 27" #### Test with Claude Desktop 1. Restart Claude Desktop 2. Look for the MCP server in the connection status 3. Ask Claude to use the tools: "What's the current time?" or "Echo 'Hello World'" ## Available Tools The MCP server provides these tools: 1. **`get_time`** - Get the current date and time 2. **`echo`** - Echo back any message you provide 3. **`calculate`** - Perform basic arithmetic (add, subtract, multiply, divide) ## Configuration Options ### Environment Variables You can customize the bridge behavior using these environment variables: - `MCP_SERVER_URL` - The URL of your .NET MCP server (default: `http://localhost:5000`) - `MCP_USERNAME` - Basic auth username (default: `admin`) - `MCP_PASSWORD` - Basic auth password (default: `password123`) ### Server Settings To change the server settings, modify `appsettings.json` in the main project: ```json { "McpServer": { "Name": "MCP Demo Server", "Version": "1.0.0", "Port": 5000 } } ``` ## Troubleshooting ### Common Issues 1. **Server not responding** - Make sure the .NET server is running (`dotnet run`) - Check that port 5000 is not blocked - Verify the server URL in the MCP configuration 2. **Authentication failures** - Verify username/password in the configuration - Check the Basic Auth credentials in the bridge 3. **Node.js bridge issues** - Ensure Node.js is installed and accessible - Check the working directory path in the configuration - Verify the `mcp-bridge.js` file exists ### Debugging Enable debug logging by setting these environment variables: ```powershell $env:MCP_DEBUG = "true" $env:ASPNETCORE_ENVIRONMENT = "Development" dotnet run ``` ### Testing the Bridge Directly You can test the Node.js bridge directly: ```powershell # Start the bridge node mcp-bridge.js # Send an initialize message echo '{"jsonrpc": "2.0", "id": "1", "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "Test", "version": "1.0.0"}}}' | node mcp-bridge.js ``` ## Security Notes ⚠️ **Important**: This configuration uses hardcoded credentials for demonstration purposes. In production: 1. Use proper authentication mechanisms 2. Enable HTTPS 3. Use environment variables for sensitive data 4. Implement proper access controls ## Support For issues or questions: 1. Check the .NET server logs 2. Verify the Node.js bridge is working 3. Test the HTTP API directly using Swagger UI at `http://localhost:5000/swagger`

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kasirajan22/DotnetMCPServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server