Back to MCP directory
publicPublicdnsLocal runtime

strawbery-mcp

一个MCP服务器,提供计算'strawberry'中'r'字符数量的工具,支持Unicode字符和返回位置信息。

article

README

🚀 草莓MCP(Strawbery-MCP)

这是一个MCP(模型上下文协议)服务器,它提供了一个工具,用于统计“strawberry”中字母“R”的正确数量。

✨ 主要特性

  • 字符计数不区分大小写。
  • 支持Unicode字符,包括CJK(中文、日文、韩文)字符。
  • 返回匹配字符的数量以及其在字符串中从1开始计数的位置。
  • 以JSON格式返回响应。

📦 安装指南

本地运行

go run main.go

容器运行

docker build -t strawbery-mcp . && docker run -p 3001:3001 strawbery-mcp

添加到OpenCode

将以下内容添加到 opencode.jsonc$.mcp 块中:

{
    "$schema": "https://opencode.ai/config.json",
    "mcp": {
        "strawbery": {
            "type": "remote",
            "url": "http://localhost:3001/sse",
            "enabled": true
        }
    }
}

💻 使用示例

工具:strawberry-count

参数

  • input(字符串,必填):要搜索的字符串。
  • character(字符串,必填):要计数的单个字符(必须恰好是一个Unicode字符)。

输入示例

{
    "character": "r",
    "input": "strawberry"
}

响应

返回一个JSON对象,包含以下内容:

  • count(整数):字符出现的次数。
  • positions(整数数组):字符出现位置的从1开始的索引。

响应示例

{
    "count": 3,
    "positions": [
        3,
        8,
        9
    ]
}

示例

  • 输入:{"input": "strawberry", "character": "r"}{"count": 3, "positions": [3,6,8]}
  • 输入:{"input": "你好", "character": "你"}{"count": 1, "positions": [1]}
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client