agentleFS
BufferoverflovvBufferoverflovv/FastMCP-Blueprint/.github/skills/add-resource/SKILL.md

add-resource

Skill0 starsChanged 7 months agoApache-2.0View on GitHub

Scaffold a new FastMCP resource following project conventions. Use when: adding a read-only data source, exposing structured or binary content via MCP, creating a resource URI, implementing a static or templated resource endpoint, or adding resource tests. Asks questions then generates the resource file, registers the import, and creates matching tests.

We split this skill into the rules it gives an agent

8 rules. 0 are common, 0 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before asking questions, read pyproject.toml to find the current package name from:

    line 19
  2. Very specific:

    Use this as PACKAGE for all file paths and imports below.

    line 25
  3. Very specific:

    Ask the following questions.

    line 29
  4. Very specific:

    If the URI contains {param} segments, this is a template resource — use @mcp.resource("uri") with matching function parameters

    line 42
  5. Very specific:

    Create src/PACKAGE/resources/RESOURCE_NAME.py using ./assets/resource_template.md as the base.

    line 47
  6. Very specific:

    Add the import line to src/PACKAGE/__main__.py after any existing resource imports:

    line 62
  7. Very specific:

    Keep # noqa: F401 — the import exists only for side-effect registration.

    line 68
  8. Very specific:

    Create tests/test_RESOURCE_NAME.py using ./assets/test_template.md as the base.

    line 72

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add a New FastMCP Resource

Scaffolds a fully wired FastMCP resource in the correct location following the conventions already used in this project.

When to use

  • Adding any MCP resource that exposes read-only data to the LLM
  • Wanting the correct URI pattern, return contract, and error handling in one step
  • Unsure about static vs. templated resources or how to serialize return values

Step 1 — Detect the package name

Before asking questions, read pyproject.toml to find the current package name from:

packages = ["src/<package_name>"]

Use this as PACKAGE for all file paths and imports below.

Step 2 — Interview the user

Ask the following questions. Use vscode_askQuestions if available.

#QuestionNotes
1Resource URIe.g. resource://config, resource://user/{user_id}
2Resource namesnake_case identifier, used for the function and file name
3What does this resource expose?One sentence — becomes the docstring
4Static or templated?Static: fixed URI. Templated: URI contains {param} segments
5Return typeplain text (str), binary (bytes), or structured data (JSON string)
6MIME typee.g. text/plain, application/json, image/png (leave blank for default)
7What should raise a ResourceError?e.g. item not found, invalid ID, upstream failure

Derive automatically:

  • If the URI contains {param} segments, this is a template resource — use @mcp.resource("uri") with matching function parameters
  • File name: RESOURCE_NAME.py under src/PACKAGE/resources/

Step 3 — Generate the resource file

Create src/PACKAGE/resources/RESOURCE_NAME.py using ./assets/resource_template.md as the base.

Fill in:

  • @mcp.resource("URI") with the full URI
  • Function signature — include path params as typed arguments for templated resources
  • Docstring from the resource description answer
  • Return type annotation (str or bytes)
  • mime_type= argument if non-default
  • ResourceError raises for stated error cases
  • Actual data retrieval or construction logic

See ./references/resource-conventions.md for exact patterns.

Step 4 — Register the import in __main__.py

Add the import line to src/PACKAGE/__main__.py after any existing resource imports:

from PACKAGE.resources import RESOURCE_NAME  # noqa: F401

Keep # noqa: F401 — the import exists only for side-effect registration.

Step 5 — Generate the test file

Create tests/test_RESOURCE_NAME.py using ./assets/test_template.md as the base.

Include at minimum:

  • A success-path test reading the resource via await client.read_resource("URI")
  • An error-path test for invalid or missing parameters (templated resources)
  • For structured data: parse and assert specific fields, not just status

Step 6 — Validate

ruff check .
pytest tests/test_RESOURCE_NAME.py -v

Fix any issues before reporting completion.

Step 7 — Report

Tell the user:

  • The path of the new resource file
  • The path of the new test file
  • What was added to __main__.py
  • The full URI to use when reading the resource with an MCP client

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.