字符计数服务

一个用于统计字符串中特定字符出现次数及其位置的MCP服务器。

  • by 3io-w
  • Go
  • 混合部署
  • 3 星标
  • 更新于
在 GitHub 查看 3io-w/strawbery-mcp

使用说明

稻草厂MCP

MCP(模型上下文协议)服务器,提供计算正确值的工具 “草莓”中的R数量。

特性

  • 不区分大小写的字符计数
  • 支持Unicode字符,包括CJK(中文、日文、韩文)
  • 返回匹配项的计数和1索引位置
  • JSON响应格式

工具:草莓计数

参数

  • input (string,必填):要搜索的字符串
  • character (string,必填):要计数的单个字符(必须恰好是一个Unicode符文)
{
  "character": "r",
  "input": "strawberry"
}

回应

JSON对象:

  • count (int):出现次数
  • positions (int数组):字符出现的1个索引位置
{
  "count": 3,
  "positions": [
    3,
    8,
    9
  ]
}

例子

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

运行服务器

此服务器使用SSE进行MCP通信。

本地

go run main.go

容器

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

添加到OpenCode

添加到 $.mcp 你的块 opencode.jsonc

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