mcpField
M
MCP Text Transform Server

MCP Text Transform Server

本地服务
github.com/msv2017开发工具074 周前更新

关于 MCP Text Transform Server

MCP Text Transform Server 是面向需要文本大小写转换的客户端的 C# .NET 9 服务,提供 Capital Case 和 snake_case 工具,也能处理 camelCase 与 PascalCase 输入。

主要功能

  1. 01转换为 Capital Case
  2. 02转换为 snake_case
  3. 03拆分 camelCase 和 PascalCase 单词
  4. 04通过 STDIO 使用 JSON-RPC 通信

适用场景

  1. 01将标识符格式化为 Capital Case
  2. 02将标识符转换为 snake_case
  3. 03转换 camelCase 或 PascalCase 输入

MCP 相关

该服务通过 STDIO 和 JSON-RPC 向 MCP 客户端提供文本转换工具。客户端可通过 MCP 接口发现并调用这些工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

MCP 文本转换服务

一个使用 C# .NET 9 实现的 Model Context Protocol (MCP) 服务,提供文本转换工具。此服务兼容 Claude Desktop 和其他 MCP 客户端。

📖 进一步了解 MCP:请访问 Model Context Protocol 官方文档,获取全面的指南和示例。

✨ 功能

此 MCP 服务提供两种强大的文本转换工具:

  1. CapitalCase 工具(capital_case)

    • 将文本转换为 Capital Case(标题格式)
    • 通过智能添加空格来处理 camelCase/PascalCase
    • 示例:"camelCaseExample" → "Camel Case Example"
  2. SnakeCase 工具(snake_case)

    • 将文本转换为 snake_case 格式
    • 处理 camelCase、PascalCase 和空格
    • 示例:"HelloWorld" → "hello_world"

🏗️ 架构

此项目使用 官方 Model Context Protocol SDK,并遵循现代 C# 实践:

  • MCP 协议兼容性:使用 ModelContextProtocol NuGet 包
  • STDIO 传输:通过标准输入/输出(JSON-RPC)通信
  • 基于特性的工具:简单的 [McpServerTool] 装饰
  • 依赖注入:内置 .NET DI 容器
  • 结构化日志记录:配置为兼容 MCP(stderr)
  • 现代 C# 特性:.NET 9、可空引用类型、异步模式

📁 项目结构

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

🚀 开始使用

先决条件
  • .NET 9.0 SDK 或更高版本
  • Claude Desktop(用于测试 MCP 集成)
构建服务
# Clone and build
git clone <repository-url>
cd test-mcp-server
dotnet build

# Test the server
dotnet run
测试工具

此服务提供以下文本转换功能:

Input: "camelCaseExample"
├── CapitalCase → "Camel Case Example"  
└── SnakeCase   → "camel_case_example"

Input: "Hello World"
├── CapitalCase → "Hello World"
└── SnakeCase   → "hello_world"

🖥️ 集成 Claude Desktop

要在 Claude Desktop 中使用此 MCP 服务,请添加以下配置:

步骤 1:找到 Claude Desktop 配置文件

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

步骤 2:添加服务配置
{
  "mcpServers": {
    "text-transform": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/path/to/your/test-mcp-server/McpServer.csproj",
        "--no-build"
      ]
    }
  }
}

将 /path/to/your/test-mcp-server 替换为你的实际项目路径:

Windows 示例:

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

macOS/Linux 示例:

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

重要说明:

  • 使用指向 McpServer.csproj 文件的绝对路径
  • 在 Windows 上使用双反斜杠(\\)进行 JSON 转义
  • 确保项目文件路径存在
  • --no-build 标志可加快服务启动速度(推荐)
步骤 3:重启 Claude Desktop

保存配置后,重启 Claude Desktop。文本转换工具即可在对话中使用。

步骤 4:在 Claude Desktop 中测试

试试以下提示词,测试集成效果:

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

🔧 开发

添加新工具

要添加新的 MCP 工具,只需向 TextTransformTools 类添加方法:

[McpServerTool]
[Description("Your tool description")]
public static string YourTool([Description("Input parameter")] string input)
{
    // Your transformation logic
    return transformedText;
}
本地测试
# 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

🛠️ 故障排除

Claude Desktop 未检测到 MCP 服务

如果 Claude Desktop 未显示文本转换工具,请按照以下步骤操作:

1. 验证服务能否在本地运行
# Test the server responds to MCP commands:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | dotnet run
2. 检查 Claude Desktop 配置

配置文件位置:

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

准确的配置格式:

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

将 /path/to/your/test-mcp-server 替换为你的实际项目路径:

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"
]

重要说明:

  • 使用指向 McpServer.csproj 文件的绝对路径
  • 在 Windows 上使用双反斜杠(\\)进行 JSON 转义
  • 确保项目文件路径存在且正确
  • command 应为 dotnet(而非完整路径)
3. 常见问题
  1. Claude Desktop 中显示“找不到服务”

    • 确认 claude_desktop_config.json 中的文件路径存在
    • 确保项目构建成功(dotnet build)
    • 检查是否已安装 .NET 9 SDK(dotnet --version)
    • 尝试在路径中使用正斜杠 /,而不是反斜杠
  2. 服务已启动,但工具不可用

    • 配置更改后,完全重启 Claude Desktop
    • 检查 Claude Desktop 的控制台/日志中是否有错误消息
    • 确认配置中的服务名称完全匹配(text-transform)
  3. 构建错误

    • 运行 dotnet restore,确保已安装所有 NuGet 包
    • 确认使用的是 .NET 9.0 SDK 或更高版本
    • 尝试先运行 dotnet clean,再运行 dotnet build
4. 高级调试

使用手动 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

查看 Claude Desktop 日志:

  • Windows:在事件查看器或 Claude 的应用程序数据文件夹中查看
  • macOS:使用 Console.app 查看日志
  • Linux:查看系统日志,或从终端运行 Claude
MCP 协议详情
  1. 服务已启动,但工具不可用

    • 配置更改后,重启 Claude Desktop
    • 在 Claude Desktop 的控制台中查看服务日志
  2. 构建错误

    • 运行 dotnet restore,确保已安装所有 NuGet 包
    • 确认使用的是 .NET 9.0 SDK 或更高版本
MCP 协议详情

此服务实现了模型上下文协议规范:

  • 传输方式:STDIO(通过 stdin/stdout 传输 JSON-RPC)
  • 协议版本:兼容 MCP 客户端
  • 工具发现:通过 [McpServerTool] 特性自动完成
  • 错误处理:标准 JSON-RPC 错误响应

有关 MCP 协议的更多详情,请参阅官方文档。

📚 技术详情

使用的 MCP SDK 功能
  • ModelContextProtocol v0.2.0-preview.2
  • 与 Claude Desktop 兼容的 STDIO 传输方式
  • 基于特性的工具注册
  • 自动参数验证和文档生成
依赖项
<PackageReference Include="ModelContextProtocol" Version="0.2.0-preview.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />

📄 许可证

本项目采用 MIT License 许可协议,详情请参阅 LICENSE 文件。

🤝 贡献

  1. Fork 此仓库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 添加新的 MCP 工具或增强功能
  4. 提交更改(git commit -m 'Add amazing feature')
  5. 推送到分支(git push origin feature/amazing-feature)
  6. 发起 Pull Request

🔮 路线图

  • 添加更多文本转换工具(kebab-case、UPPER_CASE 等)
  • 实现文本验证和清理工具
  • 添加批量文本处理支持
  • 创建全面的测试套件
  • 添加性能基准测试 "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.

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。