技能发现与安装MCP服务器

Skill Swarm 是一个用于AI智能体技能发现、安装与编排的MCP服务器,支持跨多个注册表搜索技能、信任评估和自动安装,并同步到Claude、agy、Codex等客户端,适用于需要快速扩展AI助手能力的开发场景。

  • by ancrz
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 ancrz/skill-swarm-mcp

使用说明

Skill Swarm

MCP server for AI agent skill discovery, installation, and orchestration.


The Problem

AI agents (Claude, agy, Codex) need skills to be effective. Today, finding and installing the right skill for a task is manual:

  1. Search Smithery/GitHub manually
  2. Evaluate if the server is trustworthy (stars? license? maintained?)
  3. Install and configure it by hand
  4. Repeat for every project

Skill Swarm automates the entire pipeline. The agent queries "pdf parsing" and Skill Swarm searches 5 registries (Skills.sh, MCP Registry, Smithery, Glama, GitHub), evaluates trust, installs the best match, and makes it available instantly.


How It Works

flowchart TD
    A["🤖 Agent queries:<br/>'database access'"] --> B{match_skills}
    B -->|Local skill found| C["✅ Use it"]
    B -->|No match| D[search_skills]
    D --> E["5 registries<br/>in parallel"]
    E --> F[install_skill]
    F --> G["download"]
    G --> H["security scan"]
    H --> I["trust check"]
    I --> J["validate Agent Skills format"]
    J --> L["atomic folder install<br/>~/.agents/skills/{name}/"]
    L --> K["reconcile client discovery<br/>Claude · agy · Codex"]
    C --> M{Need partial context?}
    M -->|Yes| N[cherry_pick_context]
    M -->|No| O["📄 Full skill loaded"]
    N --> P["Extract only<br/>sections you need"]

    style A fill:#8B5CF6,stroke:#6D28D9,color:#fff
    style C fill:#10B981,stroke:#059669,color:#fff
    style L fill:#10B981,stroke:#059669,color:#fff
    style F fill:#3B82F6,stroke:#2563EB,color:#fff
    style D fill:#3B82F6,stroke:#2563EB,color:#fff
    style N fill:#F59E0B,stroke:#D97706,color:#fff

Search Orchestration

Remote search uses a two-phase strategy — high-trust registries first, fallback only if needed:

flowchart LR
    Q["Query"] --> P1["Phase 1<br/>Skills.sh + MCP Registry"]
    P1 -->|">= 3 results"| D["Deduplicate<br/>+ Trust Score"]
    P1 -->|"< 3 results"| P2["Phase 2<br/>Smithery + Glama<br/>+ GitHub (if token)"]
    P2 --> D
    D --> R["Sorted Results"]

    style Q fill:#8B5CF6,stroke:#6D28D9,color:#fff
    style P1 fill:#10B981,stroke:#059669,color:#fff
    style P2 fill:#F59E0B,stroke:#D97706,color:#fff
    style D fill:#3B82F6,stroke:#2563EB,color:#fff
    style R fill:#10B981,stroke:#059669,color:#fff

Architecture

graph TB
    Agent["🤖 AI Agent (Claude, agy, Codex)"]
    Agent -->|MCP Protocol stdio| Server

    subgraph Server["skill-swarm MCP Server"]
        direction TB
        Tools["9 Tools · Python 3.12+"]
        subgraph Core["Core Engines"]
            Matcher["Matcher V2<br/>BM25F + 7 signals"]
            Trust["Trust Engine<br/>5 dimensions · git-quality"]
        end
        subgraph Infra["Infrastructure"]
            Cache["Cache Layer<br/>TTL file · 1h/24h"]
            Usage["Usage Tracker<br/>dead skill detection"]
        end
    end

    Server --> Registries
    Server --> Skills

    subgraph Registries["5 Registries"]
        SkillsSH["Skills.sh"]
        MCP["MCP Registry"]
        Smithery["Smithery"]
        Glama["Glama.ai"]
        GitHub["GitHub (+token)"]
    end

    subgraph Skills["Global Skill Discovery"]
        Canonical["~/.agents/skills/{name}/<br/>SKILL.md · scripts · references · assets"]
        ClaudeLinks["~/.claude/skills/{name}<br/>managed symlink"]
        AgyLinks["agy global skill paths<br/>managed symlinks"]
        CodexNative["Codex<br/>reads canonical source"]
        Canonical --> ClaudeLinks
        Canonical --> AgyLinks
        Canonical --> CodexNative
    end

    style Agent fill:#8B5CF6,stroke:#6D28D9,color:#fff
    style Server fill:#1E293B,stroke:#334155,color:#fff
    style Tools fill:#334155,stroke:#475569,color:#fff
    style Matcher fill:#3B82F6,stroke:#2563EB,color:#fff
    style Trust fill:#3B82F6,stroke:#2563EB,color:#fff
    style Cache fill:#475569,stroke:#64748B,color:#fff
    style Usage fill:#475569,stroke:#64748B,color:#fff
    style Canonical fill:#10B981,stroke:#059669,color:#fff
    style ClaudeLinks fill:#E1F5EE,stroke:#0F6E56,color:#04342C
    style AgyLinks fill:#E1F5EE,stroke:#0F6E56,color:#04342C
    style CodexNative fill:#E1F5EE,stroke:#0F6E56,color:#04342C

Install Pipeline

sequenceDiagram
    participant A as AI Agent
    participant S as skill-swarm
    participant R as Registries
    participant FS as Filesystem

    A->>S: install_skill("pdf-parser", url)
    S->>R: Fetch source (GitHub, npx, etc.)
    S->>S: Download complete skill folder
    S->>S: Security scan (pattern matching)
    alt scan fails
        S-->>A: ❌ Blocked (security_score < 0.5)
    end
    S->>S: Validate SKILL.md frontmatter
    S->>FS: Stage and atomically install complete folder
    S->>FS: Manage symlinks (~/.claude, ~/.gemini, ~/.agents)
    S->>S: Update manifest.json + usage tracker
    S->>S: Purge search cache
    S-->>A: ✅ InstallResult (path, agents, scores)

Quick Start

Prerequisites

  • Python 3.12+ (validated with Python 3.14 in Ubuntu under PRoot)
  • Git (for cloning skill sources)
  • GitHub token (optional, for 5000 req/hr vs 60)

Installation

git clone https://github.com/ancrz/skill-swarm-mcp.git
cd skill-swarm-mcp

# Create virtual environment and install
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

# Configure environment
cp .env.example .env

# Safely add your GitHub token without leaking it to shell history:
printf "Enter SKILL_SWARM_GITHUB_TOKEN (hidden): " && read -s val && echo && echo "SKILL_SWARM_GITHUB_TOKEN=$val" >> .env

Note on GitHub Token: Skill Swarm uses the GitHub API to calculate Mathematical Trust Scores (stars, recent activity, issues) for skills. If the token is missing, the system will completely skip raw GitHub searches to prevent inventing inaccurate scores, and will automatically defer entirely to the official alternate registries (Smithery, MCP Registry, Skills.sh, Glama).

Configure Your AI Agent Globally

Skill Swarm uses stdio transport — the AI client launches the Python process and communicates via stdin/stdout. This means the client is responsible for starting the server and passing environment variables.

How secrets work with stdio: The client launches the MCP process. Keep the GitHub token in the client environment or in a private wrapper; do not commit it to this repository.

Install the package with pip install -e . first. The editable installation makes PYTHONPATH unnecessary and lets the clients start the server from any directory. Use one persistent virtual environment and register its absolute Python path in each client; do not add a project .mcp.json, because it would shadow or conflict with the global registration.


Claude Code

Register it in the user scope:

claude mcp add --scope user skill-swarm \
  -e SKILL_SWARM_ENV_FILE="$HOME/.env" \
  -- "$PWD/.venv/bin/python" -m skill_swarm.server

Antigravity CLI (agy)

agy stores global MCP servers in ~/.gemini/config/mcp_config.json.

Register it with the CLI:

agy mcp add --env SKILL_SWARM_ENV_FILE="$HOME/.env" \
  skill-swarm "$PWD/.venv/bin/python" -m skill_swarm.server

Codex

Codex stores global MCP configuration in ~/.codex/config.toml:

cat << 'EOF' >> ~/.codex/config.toml

[mcpServers.skill-swarm]
command = "python"
args = ["-m", "skill_swarm.server"]
env = { SKILL_SWARM_ENV_FILE = "~/.env" }
EOF

Note: Run Codex from inside the virtual environment (uv run codex) so python resolves correctly.


Quick Comparison

Client Global MCP configuration Global skill discovery
Claude Code User-scoped claude mcp add --scope user ~/.claude/skills/
Antigravity CLI (agy) ~/.gemini/config/mcp_config.json ~/.gemini/config/skills/
Codex ~/.codex/config.toml ~/.agents/skills/

Verify

# Unit tests
.venv/bin/python -m pytest -q tests/test_core.py

# Confirm each global client sees the server
claude mcp list
agy mcp list
codex mcp list

9 Tools Reference

Tool Description Key Args
search_skills Search 5 registries with trust scoring query, scope, limit
match_skills BM25F + 7-signal local matching task_description, threshold
install_skill Download, scan, trust-check, install name, source, agents
uninstall_skill Remove skill + symlinks + tracking name
update_skill Check and apply updates from source name
list_skills Inventory with health and usage stats agent
get_skill_info Full metadata + content of a skill name
cherry_pick_context Extract specific markdown sections skill_name, sections
skill_health Usage analytics and dead skill detection (none)

See TOOLS.md for complete parameter reference and examples.


Skill Directory Compliance

Skills follow the Agent Skills standard with one user-global source:

~/.agents/skills/                   # Global source; Codex reads it directly
├── {skill-name}/
│   └── SKILL.md                    # Skill content (always SKILL.md)
├── manifest.json                   # Installed skills registry
├── .usage.json                     # Usage tracking data
└── .cache/                         # TTL-based search/trust cache

~/.claude/skills/                   # Agent-specific (symlinks)
├── {skill-name} -> ~/.agents/skills/{skill-name}
└── ...

~/.gemini/config/skills/            # agy current global path (symlinks)
├── {skill-name} -> ~/.agents/skills/{skill-name}
└── ...

~/.gemini/antigravity-cli/skills/  # agy migration compatibility
├── {skill-name} -> ~/.agents/skills/{skill-name}
└── ...
  • The folder name identifies the skill
  • The file is always SKILL.md (standard compliance)
  • Agent directories contain directory symlinks to the global source
  • Legacy ~/.agent/skills/ content is migrated without overwriting conflicts

Trust Score Engine

Every remote search result includes a trust score (0.0-1.0) computed from 5 git-quality dimensions:

pie title Trust Score Weights
    "Maintenance" : 25
    "Security" : 25
    "Recency" : 20
    "Popularity" : 20
    "Completeness" : 10
Dimension Weight Signals
Recency 0.20 Exponential decay since last push (half-life: 180 days)
Popularity 0.20 Log-normalized stars, forks, watchers
Maintenance 0.25 Push frequency, open issues ratio
Security 0.25 License trust level (MIT=1.0, GPL=0.5, none=0.1), archived penalty
Completeness 0.10 Description, homepage, topics, README presence

Verdicts:

Score Verdict Action
>= 0.75 TRUST Safe to auto-install
0.50-0.74 CAUTION Show to agent for review
0.25-0.49 WARNING Manual review recommended
< 0.25 REJECT Block installation

Matcher V2 — BM25F + Multi-Signal Scoring

Local skill matching uses 7 weighted signals:

graph LR
    RQ["Raw Query"] --> NQ["Normalize<br/>stopword removal"]
    NQ --> Q["Keywords"]
    Q --> E["Exact Match<br/>w=30"]
    Q --> P["Prefix Match<br/>w=20"]
    Q --> PH["Phrase Match<br/>w=15"]
    Q --> B["BM25F<br/>w=15"]
    Q --> J["Jaccard Tags<br/>w=10"]
    Q --> FN["Fuzzy Name<br/>w=7"]
    Q --> FD["Fuzzy Desc<br/>w=3"]

    E --> S["Σ Weighted Score<br/>0.0 – 1.0"]
    P --> S
    PH --> S
    B --> S
    J --> S
    FN --> S
    FD --> S

    style RQ fill:#F59E0B,stroke:#D97706,color:#fff
    style NQ fill:#F59E0B,stroke:#D97706,color:#fff
    style Q fill:#8B5CF6,stroke:#6D28D9,color:#fff
    style S fill:#10B981,stroke:#059669,color:#fff
    style E fill:#EF4444,stroke:#DC2626,color:#fff
    style P fill:#F97316,stroke:#EA580C,color:#fff
    style B fill:#3B82F6,stroke:#2563EB,color:#fff
Signal Weight Description
Exact match 30 Query equals skill name
Prefix match 20 Skill name starts with query
Phrase match 15 Query found as substring in any field
BM25F 15 Field-weighted relevance (name=3x, tags=2x, desc=1x)
Jaccard tags 10 Set similarity on tags
Fuzzy name 7 Typo-tolerant name matching (rapidfuzz)
Fuzzy description 3 Partial match on description

BM25F parameters optimized for small corpus (10-100 skills): k1=1.2, b=0.3.


Platform Support

Platform Status Notes
Linux Full support Primary development platform
macOS Full support Same Python ecosystem
Windows Full support Native symlinks supported (see below)

Windows Symlinks

Skill Swarm uses directory symlinks (os.symlink) to share skills across agents. Windows supports native NTFS symlinks:

Windows Version Requirement
Windows 11 No configuration needed — symlinks work for all users
Windows 10 (Creators Update+) Enable Developer Mode: Settings → Update & Security → For Developers
Windows 10 (older builds) Run as Administrator

Python's os.symlink() works natively on Windows when the above permissions are met. No WSL required.

Manual creation (if needed):

# PowerShell
New-Item -ItemType SymbolicLink -Path "$HOME\.claude\skills\my-skill" -Target "$HOME\.agents\skills\my-skill"

# Command Prompt (Administrator)
mklink /D "%USERPROFILE%\.claude\skills\my-skill" "%USERPROFILE%\.agents\skills\my-skill"

AI Agent Compatibility:

Client Integration Skill directory
Claude Code MCP stdio + symlinks ~/.claude/skills/
agy MCP stdio + symlinks ~/.gemini/config/skills/
Codex MCP stdio + native source ~/.agents/skills/

Configuration Reference

All settings are loaded from environment variables (prefix: SKILL_SWARM_):

Variable Default Description
SKILL_SWARM_GITHUB_TOKEN (empty) GitHub PAT for API access (5000 req/hr)
SKILL_SWARM_CACHE_SEARCH_TTL 3600 Search cache TTL in seconds
SKILL_SWARM_CACHE_TRUST_TTL 86400 Trust score cache TTL in seconds
SKILL_SWARM_SEARCH_TIMEOUT 15.0 HTTP timeout for registry queries
SKILL_SWARM_SEARCH_MAX_RESULTS 10 Max results per search
SKILL_SWARM_SECURITY_THRESHOLD 0.5 Min security scan score to install
SKILL_SWARM_SKILLSSH_ENABLED true Enable Skills.sh as primary registry
SKILL_SWARM_SKILLSSH_NPX_PATH npx Path to npx binary for skills find
SKILL_SWARM_SKILLSSH_GITHUB_FALLBACK true Use GitHub topic search when npx unavailable
SKILL_SWARM_SKILLSSH_SEARCH_TIMEOUT 30.0 Timeout for npx subprocess calls
SKILL_SWARM_SEARCH_PHASE1_MIN_RESULTS 3 Phase 2 search trigger threshold

Project Structure

skill-swarm-mcp/
├── src/skill_swarm/
│   ├── server.py              # MCPServer entry point (9 tools)
│   ├── config.py              # Pydantic Settings + path helpers
│   ├── models.py              # Data models (SkillInfo, TrustScore, etc.)
│   ├── core/
│   │   ├── scanner.py         # Security pattern scanner
│   │   ├── normalizer.py      # Query normalization (stopword removal)
│   │   ├── matcher.py         # BM25F + multi-signal scoring
│   │   ├── installer.py       # Download, scan, install pipeline
│   │   ├── registry.py        # 5-registry parallel search (Skills.sh primary)
│   │   ├── trust.py           # Git-quality trust scoring engine
│   │   ├── cache.py           # TTL file-based cache
│   │   └── usage.py           # Skill usage tracking
│   └── tools/
│       ├── search.py          # search_skills implementation
│       ├── install.py         # install/uninstall wiring
│       ├── inventory.py       # list/match/get_info wiring
│       └── cherry_pick.py     # Section extraction
├── agnos/                         # Agnostic specs (paradigm bridge)
│   ├── spec-orchestration.md
│   ├── spec-task-dependencies.md
│   └── spec-agent-dispatch.md
├── skill/
│   ├── SKILL.md               # Self-describing skill file
│   └── references/            # Skill reference docs
├── tests/
│   ├── test_core.py           # Unit tests (25)
│   ├── test_e2e_effectiveness.py  # E2E V1 (19 tests)
│   └── test_e2e_v2.py         # E2E V2 — trust, cache, BM25F (19 tests)
├── LICENSE                    # Apache 2.0
├── README.md                  # This file
├── TOOLS.md                   # Complete tool reference
├── pyproject.toml             # Python package config
├── uv.lock                    # Reproducible dependency lock
├── .env.example               # Environment template
└── .gitignore

Development

# Install with dev dependencies
pip install -e ".[dev]"

# Run all non-network tests
.venv/bin/python -m pytest tests/ -v -m "not network"

# Run with network tests (requires internet access)
.venv/bin/python -m pytest tests/ -v

# Test a single search
.venv/bin/python -c "
import asyncio, sys, json
sys.path.insert(0, 'src')
from skill_swarm.tools.search import search_skills
results = asyncio.run(search_skills('filesystem', scope='remote', limit=3))
for r in results:
    trust = r.trust.score if r.trust else 'N/A'
    print(f'{r.name} ({r.source}) trust={trust}')
"

License

Apache License 2.0 — see LICENSE for details.

Copyright 2025 Anthony Cruz

Built with MCP Protocol and AI-assisted engineering.

⬆ Back to Top