test-mcp-server

msv2017/test-mcp-server

3.2

If you are the rightful owner of test-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This document provides a comprehensive overview of a Model Context Protocol (MCP) server implementation in C# .NET 9, designed for text transformation tasks.

Tools
2
Resources
0
Prompts
0

MCP Text Transform Server

A Model Context Protocol (MCP) server implementation in C# .NET 9 that provides text transformation tools. This server is compatible with Claude Desktop and other MCP clients.

šŸ“– Learn more about MCP: Visit the official Model Context Protocol documentation for comprehensive guides and examples.

✨ Features

This MCP server provides two powerful text transformation tools:

  1. CapitalCase Tool (capital_case)

    • Converts text to Capital Case (Title Case) format
    • Handles camelCase/PascalCase by intelligently adding spaces
    • Example: "camelCaseExample" → "Camel Case Example"
  2. SnakeCase Tool (snake_case)

    • Converts text to snake_case format
    • Handles camelCase, PascalCase, and spaces
    • Example: "HelloWorld" → "hello_world"

šŸ—ļø Architecture

This project uses the official Model Context Protocol SDK and follows modern C# practices:

  • MCP Protocol Compliance: Uses ModelContextProtocol NuGet package
  • STDIO Transport: Communicates via standard input/output (JSON-RPC)
  • Attribute-Based Tools: Simple [McpServerTool] decoration
  • Dependency Injection: Built-in .NET DI container
  • Structured Logging: Configured for MCP compatibility (stderr)
  • Modern C# Features: .NET 9, nullable reference types, async patterns

šŸ“ Project Structure

McpServer/
ā”œā”€ā”€ Tools/                     # MCP tool implementations
│   └── TextTransformTools.cs  # Capital case & snake case tools
ā”œā”€ā”€ Program.cs                 # MCP server entry point
ā”œā”€ā”€ McpServer.csproj          # Project file with MCP SDK
└── README.md                 # This documentation

šŸš€ Getting Started

Prerequisites

  • .NET 9.0 SDK or later
  • Claude Desktop (for testing MCP integration)

Building the Server

# Clone and build
git clone <repository-url>
cd test-mcp-server
dotnet build

# Test the server
dotnet run

Testing the Tools

The server provides these text transformation capabilities:

Input: "camelCaseExample"
ā”œā”€ā”€ CapitalCase → "Camel Case Example"  
└── SnakeCase   → "camel_case_example"

Input: "Hello World"
ā”œā”€ā”€ CapitalCase → "Hello World"
└── SnakeCase   → "hello_world"

šŸ–„ļø Claude Desktop Integration

To use this MCP server with Claude Desktop, add the following configuration:

Step 1: Locate Claude Desktop Config

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json

Step 2: Add Server Configuration

{
  "mcpServers": {
    "text-transform": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/path/to/your/test-mcp-server/McpServer.csproj",
        "--no-build"
      ]
    }
  }
}

Replace /path/to/your/test-mcp-server with your actual project path:

Windows example:

{
  "mcpServers": {
    "text-transform": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "C:\\Users\\YourName\\projects\\test-mcp-server\\McpServer.csproj",
        "--no-build"
      ]
    }
  }
}

macOS/Linux example:

{
  "mcpServers": {
    "text-transform": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/home/username/projects/test-mcp-server/McpServer.csproj",
        "--no-build"
      ]
    }
  }
}

Important notes:

  • Use absolute paths to the McpServer.csproj file
  • Use double backslashes (\\) on Windows for JSON escaping
  • Ensure the project file path exists
  • The --no-build flag speeds up server startup (recommended)

Step 3: Restart Claude Desktop

After saving the configuration, restart Claude Desktop. The text transformation tools will be available in your conversations.

Step 4: Test in Claude Desktop

Try these prompts to test the integration:

"Please convert 'HelloWorldExample' to capital case"
"Transform 'My Example Text' to snake_case format"  
"Convert 'camelCaseVariable' to title case"

šŸ”§ Development

Adding New Tools

To add new MCP tools, simply add methods to the TextTransformTools class:

[McpServerTool]
[Description("Your tool description")]
public static string YourTool([Description("Input parameter")] string input)
{
    // Your transformation logic
    return transformedText;
}

Testing Locally

# Build and run
dotnet run

# Test with JSON-RPC (the server expects MCP protocol messages)
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | dotnet run

šŸ› ļø Troubleshooting

Claude Desktop Not Detecting MCP Server

If Claude Desktop doesn't show the text transformation tools, follow these steps:

1. Verify Server Works Locally
# Test the server responds to MCP commands:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | dotnet run
2. Check Claude Desktop Configuration

Location of config file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Exact configuration format:

{
  "mcpServers": {
    "text-transform": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/path/to/your/test-mcp-server/McpServer.csproj",
        "--no-build"
      ]
    }
  }
}

Replace /path/to/your/test-mcp-server with your actual project path:

Windows:

"args": [
  "run",
  "--project",
  "C:\\Users\\YourName\\projects\\test-mcp-server\\McpServer.csproj",
  "--no-build"
]

macOS/Linux:

"args": [
  "run",
  "--project",
  "/home/username/projects/test-mcp-server/McpServer.csproj",
  "--no-build"
]

Important notes:

  • Use absolute paths to the McpServer.csproj file
  • Use double backslashes (\\) on Windows for JSON escaping
  • Ensure the project file path exists and is correct
  • The command should be dotnet (not full path)
3. Common Issues
  1. "Server not found" in Claude Desktop

    • Verify the file path in claude_desktop_config.json exists
    • Ensure the project builds successfully (dotnet build)
    • Check that .NET 9 SDK is installed (dotnet --version)
    • Try using forward slashes / instead of backslashes in paths
  2. Server starts but tools not available

    • Restart Claude Desktop completely after configuration changes
    • Check Claude Desktop's console/logs for error messages
    • Verify the server name in config matches exactly (text-transform)
  3. Build errors

    • Run dotnet restore to ensure all NuGet packages are installed
    • Verify you have .NET 9.0 SDK or later
    • Try dotnet clean followed by dotnet build
4. Advanced Debugging

Test with manual JSON-RPC:

# Initialize the server
echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | dotnet run

# List available tools  
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}' | dotnet run

# Test tool execution
echo '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "CapitalCase", "arguments": {"text": "hello world"}}}' | dotnet run

Check Claude Desktop logs:

  • Windows: Look in Event Viewer or Claude's application data folder
  • macOS: Use Console.app to view logs
  • Linux: Check system logs or run Claude from terminal

MCP Protocol Details

  1. Server starts but tools not available

    • Restart Claude Desktop after configuration changes
    • Check the server logs in Claude Desktop's console
  2. Build errors

    • Run dotnet restore to ensure all NuGet packages are installed
    • Verify you have .NET 9.0 SDK or later

MCP Protocol Details

This server implements the Model Context Protocol specification:

  • Transport: STDIO (JSON-RPC over stdin/stdout)
  • Protocol Version: Compatible with MCP clients
  • Tool Discovery: Automatic via [McpServerTool] attributes
  • Error Handling: Standard JSON-RPC error responses

For more details about the MCP protocol, see the official documentation.

šŸ“š Technical Details

MCP SDK Features Used

  • ModelContextProtocol v0.2.0-preview.2
  • STDIO transport for Claude Desktop compatibility
  • Attribute-based tool registration
  • Automatic parameter validation and documentation

Dependencies

<PackageReference Include="ModelContextProtocol" Version="0.2.0-preview.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />

šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Add your new MCP tools or enhancements
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

šŸ”® Roadmap

  • Add more text transformation tools (kebab-case, UPPER_CASE, etc.)
  • Implement text validation and sanitization tools
  • Add support for batch text processing
  • Create comprehensive test suite
  • Add performance benchmarks "ServerName": "Text Transform MCP Server", "Version": "1.0.0", "Port": 8080, "Logging": { "LogLevel": "Information", "EnableStructuredLogging": true } } }

## Health Check

A health check endpoint is available at `/health` to verify the server status.

## Development

### Code Style

The project uses `.editorconfig` for consistent code formatting and follows:

- PascalCase for classes, methods, properties
- camelCase for private fields and parameters
- Underscore prefix for private fields (`_fieldName`)
- File-scoped namespaces
- Nullable reference types enabled

### Logging

Structured logging is implemented using `ILogger<T>` with appropriate log levels:

- **Debug**: Detailed transformation steps
- **Information**: Tool execution and server lifecycle
- **Warning**: Invalid inputs or missing tools
- **Error**: Exceptions and failures

### Testing

The project structure supports unit testing with:

- Dependency injection for testability
- Interface-based programming
- Separation of concerns

## MCP Protocol

This server implements the Model Context Protocol for integration with MCP-compatible clients. The tools can be discovered and executed through the standard MCP tool calling interface.

## License

This project is provided as-is for educational and development purposes.