mcpField
O
Oh My Posh Validator

Oh My Posh Validator

远程服务
ohmyposh.dev开发工具23.7k1 周前更新

关于 Oh My Posh Validator

Oh My Posh Validator 是面向 oh-my-posh 用户的 MCP 服务,可检查完整配置和单个片段,支持 JSON、YAML、TOML,并返回详细错误与警告。

主要功能

  1. 01验证完整配置
  2. 02验证单个片段
  3. 03支持 JSON、YAML 和 TOML
  4. 04返回路径级错误和警告

适用场景

  1. 01使用配置前检查有效性
  2. 02将片段加入配置前单独测试

MCP 相关

它通过 HTTP 向 MCP 客户端提供 `validate_config` 和 `validate_segment` 工具,也可返回服务信息和工具列表。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://ohmyposh.dev/api/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

2
参数类型必填说明
formatenum否配置的格式(未指定时自动检测)json | yaml | toml | auto
contentstring是以字符串形式提供的配置内容(JSON、YAML 或 TOML)

详细介绍


title: MCP 验证函数 description: '用于验证 oh-my-posh 配置的模型上下文协议服务器 Azure Function'

概述

此目录包含用于验证 oh-my-posh 配置的模型上下文协议(MCP)服务 Azure Function。

端点

  • POST /api/mcp - 处理验证请求的 MCP 服务端点
  • GET /api/mcp - 返回服务信息和可用工具

支持的工具

validate_config

验证 oh-my-posh 配置。

  • 支持 JSON、YAML 和 TOML 格式
  • 返回包含 JSON 路径的详细验证错误
validate_segment

验证片段代码段(单个提示词片段)。

  • 根据片段架构定义进行验证
  • 可在将单个片段添加到完整配置前用于测试
  • 支持 JSON、YAML 和 TOML 格式

用法

作为 MCP 服务

配置 MCP 客户端以连接到此服务:

{
  "mcpServers": {
    "oh-my-posh-validator": {
      "type": "http",
      "url": "https://ohmyposh.dev/api/mcp"
    }
  }
}
直接发送 HTTP 请求
获取服务信息
curl https://ohmyposh.dev/api/mcp
列出可用工具
curl -X POST https://ohmyposh.dev/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": 1
  }'
验证配置
curl -X POST https://ohmyposh.dev/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "validate_config",
      "arguments": {
        "content": "{\"$schema\":\"https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/
themes/schema.json\",\"blocks\":[]}",
        "format": "json"
      }
    },
    "id": 1
  }'
验证片段代码段
curl -X POST https://ohmyposh.dev/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "validate_segment",
      "arguments": {
        "content": "{\"type\":\"path\",\"style\":\"powerline\",\"foreground\":\"#ffffff\",\"background\":\"#61AFEF\",\"template\":\" {{ .Path }} \"}",
        "format": "json"
      }
    },
    "id": 2
  }'

响应格式

验证结果包括:

  • valid:表示配置是否有效的布尔值
  • errors:验证错误数组(如果有)
  • warnings:警告数组(最佳实践、弃用项)
  • detectedFormat:检测到或指定的格式
  • parsedConfig:解析后的配置对象(用于调试)

响应示例:

{
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{
          \"valid\": true,
          \"errors\": [],
          \"warnings\": [
            {
              \"path\": \"$schema\",
              \"message\": \"Consider adding \\\"$schema\\\" property for better editor support.\",
              \"type\": \"recommendation\"
            }
          ],
          \"detectedFormat\": \"json\",
          \"parsedConfig\": {...}
        }"
      }
    ]
  },
  "id": 1
}

开发

本地测试:

cd website/api
npm install
npm start

然后向 http://localhost:7071/api/mcp 发送请求

发布到 MCP Registry

此服务通过 GitHub Actions 发布到 MCP Registry。

发布

推送版本标签时会自动触发发布(与 oh-my-posh 发布相同):

git tag v9.0.0
git push origin v9.0.0

工作流将:

  1. 从标签中提取版本(例如,v9.0.0 → 9.0.0)
  2. 更新 server.json 版本以保持一致
  3. 验证 server.json 文件
  4. 使用 GitHub OIDC 向 MCP Registry 进行身份验证
  5. 将服务发布到注册表

注意:MCP 服务版本将自动与 oh-my-posh 版本保持同步。

文件
  • server.json - MCP Registry 服务配置
  • server.schema.json - 用于验证的 JSON 架构
  • validate-server.js - 验证脚本
  • .github/workflows/publish-mcp.yml - GitHub Actions 工作流
在本地验证 server.json
cd website/api
npm install
cd mcp
node validate-server.js

评论

支持 Markdown

第一次接触 MCP?

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

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