agentleFS
Teapot-AgencyTeapot-Agency/teapot-seo-skills/skills/remote-mcp-client/SKILL.md

remote-mcp-client

Skill0 starsChanged 7 months agoMITView on GitHub

Placeholder skill pre vlastný remote MCP server. Zopakuj túto šablónu pre každý vlastný MCP backend (GSC, GA4, Google Ads, atď.) — nahraď MCP_URL, KEYCHAIN_SERVICE a názvy nástrojov. Slúži ako shared client helper pre dátové skills (`seo-content-brief` volá GSC/Ahrefs cez tento pattern).

  • Installs packages

The file

Files
SKILL.md

remote-mcp-client (PLACEHOLDER)

Tento skill je šablóna, nie funkčný klient. Original v teapot-seo-skills repo bol naviazaný na privátny https://mcp.teapot.sk/mcp. Zachoval som len rozhranie/pattern — tvoju vlastnú MCP URL si doplň nižšie.

Ako to nahradiť svojím MCP serverom

  1. Vytvor scripts/mcp_client.py podľa nižšieho šablónového vzoru.
  2. Nahraď konštanty na vrchu súboru:
    DEFAULT_MCP_URL = "https://YOUR-MCP-HOST/mcp"   # napr. https://mcp.example.com/mcp
    KEYCHAIN_SERVICE = "your-mcp-name"              # napr. "my-gsc-mcp"
    KEYCHAIN_ACCOUNT = "default"                    # alebo username
  3. OAuth flow: ak tvoj MCP používa OAuth 2.1 (čo je štandard pre remote MCP od konca 2025), browser-based PKCE flow funguje out-of-the-box — webbrowser.open(authorize_url) + lokálny HTTPServer na callback.
  4. Token storage: macOS Keychain cez security add-generic-password (Linux: secret-tool, Windows: keyring). Nikdy neukladaj tokeny do plain súborov.
  5. Bearer override: env premenná YOUR_MCP_BEARER_TOKEN ako emergency override (nikdy neprintuj hodnoty).

Šablónový vzor (skrátený)

#!/usr/bin/env python3
"""Remote MCP client template — replace constants below."""

import asyncio, base64, hashlib, json, os, secrets, subprocess, sys, time, webbrowser
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import parse_qs, urlencode, urlparse

import httpx
from fastmcp import Client

# === REPLACE THESE ===
DEFAULT_MCP_URL = "https://YOUR-MCP-HOST/mcp"
KEYCHAIN_SERVICE = "your-mcp-name"
KEYCHAIN_ACCOUNT = "default"
# =====================

class BearerAuth(httpx.Auth):
    def __init__(self, token): self.token = token
    def auth_flow(self, request):
        request.headers["Authorization"] = f"Bearer {self.token}"
        yield request

# Keychain helpers — macOS only; for Linux/Windows use `keyring` package
def keychain_get():
    r = subprocess.run(
        ["security", "find-generic-password", "-s", KEYCHAIN_SERVICE,
         "-a", KEYCHAIN_ACCOUNT, "-w"],
        capture_output=True, text=True,
    )
    return r.stdout.strip() if r.returncode == 0 else None

def keychain_set(value):
    subprocess.run(
        ["security", "add-generic-password", "-U", "-s", KEYCHAIN_SERVICE,
         "-a", KEYCHAIN_ACCOUNT, "-w", value],
        check=True,
    )

# OAuth PKCE flow — implement authorize_url / token_url per your provider
# ...

# Tool call wrapper
async def call_tool(name: str, arguments: dict | None = None):
    token = keychain_get() or os.environ.get("YOUR_MCP_BEARER_TOKEN")
    if not token:
        raise RuntimeError("Not authenticated. Run: python mcp_client.py auth login")
    async with Client(DEFAULT_MCP_URL, auth=BearerAuth(token)) as c:
        return await c.call_tool(name, arguments or {})

# CLI: tools | call <name> [--arguments JSON] | auth login | auth status | auth logout

Plnohodnotná implementácia (vrátane PKCE OAuth callback servera, token refresh, list-tools) — pozri fastmcp docs alebo zopakuj pattern z ľubovoľného public OAuth 2.1 PKCE klienta.

Použitie z iného skillu

Skills v tomto repo (seo-content-brief, atď.) volajú remote MCP cez subprocess:

uv run --quiet --with fastmcp --with httpx \
  python ~/.claude/skills/remote-mcp-client/scripts/mcp_client.py \
  call your_tool_name --arguments '{"key":"value"}'

Volanie cez uv run izoluje deps a nepotrebuje globálny pip install.

Bezpečnostné pravidlá

  • Nikdy neprintuj hodnoty tokenov ani do logov, ani do stdoutu.
  • security (macOS) ukladá iba do user keychainu — keď je locked, vráti chybu.
  • Refresh tokens majú dlhý TTL — ošetri rotáciu (uloženie nového refresh-tokenu pri každom renew).
  • HTTPS only — odmietni http:// MCP URL.
  • State parameter v OAuth flow musí byť cryptographically random a one-time-use (CSRF protection).

Prečo placeholder

Pôvodný teapot-mcp skill v privátnej verzii má vyše 600 riadkov a je tightly coupled s autorovou mcp.teapot.sk doménou (Google APIs proxy + custom tools). Pre verejný repo by bolo vystavovanie tej implementácie a) zbytočné (každý má iný MCP backend), b) potenciálne nebezpečné (špecifické endpointy, naming conventions). Šablóna ti dá pattern, ktorý si naplníš podľa svojho MCP-u.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.