mcp-server

A project guide for building a Python MCP server that connects to esa.io, a team knowledge-sharing service, through its API.

In plain words
What is it for?
Use it when implementing or extending esa.io features such as reading, searching, creating, updating, or deleting posts, while managing credentials through environment variables.
Why use it?
It gives the coding agent a staged plan for setup, API operations, tests, code checks, logging, and documentation. It also records that Cursor may need to reload the MCP connection after server changes.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/scnsh/mcp-esa-server-python/mcp-server
Clone the repo
git clone --depth 1 https://github.com/scnsh/mcp-esa-server-python

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,040 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01040
Opus 5 $0.00000 $0.00520
Sonnet 5 $0.00000 $0.00208
Haiku 4.5 $0.00000 $0.00104

Measured yesterday against content hash e226a99ffa99, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mcp-server scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/mcp-server.mdc · 86 lines

What it actually says

プロジェクト

esa.ioのAPIを使用して、基本的な操作を行えるMCPサーバーを作る .envで完了変数を管理し、ESA_TOKEN, ESA_TEAM_NAMEでそれぞれAPIトークンとチーム名を管理する。

esa.ioのAPIについては https://docs.esa.io/posts/102 を参照。

使用技術

  • python
  • uv

開発計画

  1. 基盤構築フェーズ

    • Pythonプロジェクト初期化 (uv init)
    • 環境変数設定 (.env)
    • APIクライアント基礎 (認証、ベースURL)
  2. コア機能実装フェーズ

    • ユーザー情報取得 (/user, テスト)
    • 記事一覧取得 (/posts, 検索、テスト)
    • 記事詳細取得 (/posts/:post_number, テスト)
    • エラー処理
  3. 追加機能と改善フェーズ

    • 記事作成 (POST /posts, テスト)
    • 記事更新 (PATCH /posts/:post_number, テスト)
    • 記事削除 (DELETE /posts/:post_number, テスト)
  4. ドキュメント整理

    • ドキュメント作成 (docs/)

進め方のポイント

  • フェーズごとに git commit
  • TDD (テスト駆動開発)
  • コードを修正したらテスト (pytest) とフォーマット/リントチェック (ruff format, ruff check) を実行する
  • 必要に応じて機能追加 (コメント等)
  • サーバーのドキュメント作成

FastMCPツールでのロギング

  • 注意: MCPツールの main 関数内でのロギングに print を使用しないでください。
  • 推奨: 常に logging パッケージを使用してください。
  • print はpytestのコードでのみ使用してください。
  • 必要に応じて logger.info()logger.warn()logger.error()logger.debug() を使用してください。

FastMCPサーバー開発ノート

  • MCPサーバーのコード (main.py またはその依存関係) を変更 (ツールの追加/削除、サーバー設定の変更) した後は、CursorでMCPサーバー情報を 再読み込み する必要があります。
  • ツールを追加した直後に「見つからない」と表示される場合は、CursorでMCPサーバー接続を再読み込みしてみてください。
  • 変更が完全に認識されるまでに、複数回の再読み込みが必要になる場合があります。

環境変数とインポート

  • モジュールのインポート時に即座に実行されるコード (例: src/esa_client.py のトップレベルでの環境変数チェック) には注意してください。
  • サーバーを起動する前に、必要な環境変数 (ESA_TOKEN, ESA_TEAM_NAME) が正しく設定されていること (例: .envdotenv 経由で) を確認してください。

その他の注意点 (必要に応じて追記)

リント/フォーマットエラーを優先対応

リンターやフォーマッターのエラーが発生した場合は、直ちに修正してください。これらのエラーが解決されるまで、他のタスクに進ないでください。

定期的なフォーマットとリントチェック

コードの品質と一貫性を確保するために、定期的に ruff format && ruff check を実行することを忘れないでください。

追加タスク (Geminiによる)

no-unused-vars (未使用の変数)

  • 対応: 未使用のインポートや変数は完全に削除してください。
  • 禁止: アンダースコアプレフィックス (例: _variable) を使用したり、未使用のコードをコメントアウトしたりしないでください。

一般的な未使用コード

  • 対応: 現在使用されていない、または直ちに使用する予定のないコードは削除してください。
  • 理由: コードベースをクリーンで焦点の合った状態に保ちます。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 86 lines · 0 tokens per session scan A e226a99ffa99

Subscribe to this mod's changes

mcp-server is a cursor rule published in the GitHub repository scnsh/mcp-esa-server-python (1 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,040 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.