Get the FREE Ultimate OpenClaw Setup Guide →

mcp-resource-uri-designer

Scanned
npx machina-cli add skill a5c-ai/babysitter/mcp-resource-uri-designer --openclaw
Files (1)
SKILL.md
4.2 KB

MCP Resource URI Designer

Design and implement resource URI schemes for MCP servers.

Capabilities

  • Design URI schemes for resources
  • Create URI template patterns
  • Generate URI parsing utilities
  • Document resource hierarchies
  • Implement content type mapping
  • Create resource discovery

Usage

Invoke this skill when you need to:

  • Design URI schemes for MCP resources
  • Create URI template patterns
  • Implement resource hierarchies
  • Document resource APIs

Inputs

ParameterTypeRequiredDescription
domainstringYesResource domain (e.g., files, database)
resourcesarrayYesResource definitions
languagestringNoImplementation language (default: typescript)

Resource Structure

{
  "domain": "database",
  "resources": [
    {
      "pattern": "db://{database}/tables/{table}",
      "name": "Database Table",
      "description": "Access database table schema and data",
      "mimeType": "application/json",
      "parameters": {
        "database": { "description": "Database name" },
        "table": { "description": "Table name" }
      }
    }
  ]
}

Generated Patterns

TypeScript URI Handler

import { Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';

// URI Templates
const URI_TEMPLATES = {
  table: 'db://{database}/tables/{table}',
  schema: 'db://{database}/schema',
  query: 'db://{database}/query/{queryId}',
} as const;

// Parse URI to extract parameters
export function parseResourceUri(uri: string): {
  type: keyof typeof URI_TEMPLATES;
  params: Record<string, string>;
} | null {
  const patterns = [
    { type: 'table' as const, regex: /^db:\/\/([^/]+)\/tables\/([^/]+)$/ },
    { type: 'schema' as const, regex: /^db:\/\/([^/]+)\/schema$/ },
    { type: 'query' as const, regex: /^db:\/\/([^/]+)\/query\/([^/]+)$/ },
  ];

  for (const { type, regex } of patterns) {
    const match = uri.match(regex);
    if (match) {
      if (type === 'table') {
        return { type, params: { database: match[1], table: match[2] } };
      } else if (type === 'schema') {
        return { type, params: { database: match[1] } };
      } else if (type === 'query') {
        return { type, params: { database: match[1], queryId: match[2] } };
      }
    }
  }
  return null;
}

// Build URI from parameters
export function buildResourceUri(
  type: keyof typeof URI_TEMPLATES,
  params: Record<string, string>
): string {
  let uri = URI_TEMPLATES[type];
  for (const [key, value] of Object.entries(params)) {
    uri = uri.replace(`{${key}}`, encodeURIComponent(value));
  }
  return uri;
}

// List available resource templates
export function listResourceTemplates(): ResourceTemplate[] {
  return [
    {
      uriTemplate: URI_TEMPLATES.table,
      name: 'Database Table',
      description: 'Access database table schema and data',
      mimeType: 'application/json',
    },
    {
      uriTemplate: URI_TEMPLATES.schema,
      name: 'Database Schema',
      description: 'Full database schema information',
      mimeType: 'application/json',
    },
  ];
}

URI Design Guidelines

Scheme Selection

  • file:// - File system resources
  • db:// - Database resources
  • http://, https:// - Web resources
  • git:// - Git repository resources
  • Custom schemes for domain-specific resources

Hierarchy Patterns

db://{database}/tables/{table}
db://{database}/tables/{table}/rows/{rowId}
db://{database}/views/{view}
db://{database}/functions/{function}

file:///{path}
file:///projects/{project}/src/{file}

git://{repo}/branches/{branch}/files/{path}

Workflow

  1. Analyze domain - Understand resource types
  2. Design scheme - Choose URI scheme
  3. Define templates - Create URI patterns
  4. Generate parser - URI parsing utilities
  5. Create builder - URI construction helpers
  6. Document resources - API documentation

Target Processes

  • mcp-resource-provider
  • mcp-server-bootstrap
  • mcp-tool-documentation

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/mcp-resource-uri-designer/SKILL.mdView on GitHub

Overview

This skill lets you design and implement resource URI schemes for MCP servers. It covers creating URI templates, parsing/building utilities, documenting resource hierarchies, and mapping content types to support resource discovery and API consistency.

How This Skill Works

Provide domain, resources, and optional language to generate typed URI templates (e.g., db://{database}/tables/{table}). The skill outputs parsing and building utilities (parseResourceUri, buildResourceUri) and a list of available templates, enabling consistent URI construction and discovery across MCP resources.

When to Use It

  • Design a new URI scheme for a MCP resource domain (e.g., database, files)
  • Create URI template patterns and documentation for APIs
  • Implement parsing and building utilities for URIs
  • Map content types to resources and enable resource discovery
  • Document and validate resource hierarchies across domains

Quick Start

  1. Step 1: Define the domain and resource definitions (domain, resources).
  2. Step 2: Generate URI templates and implement parseResourceUri and buildResourceUri (e.g., in TypeScript).
  3. Step 3: List available templates, document the hierarchy, and add tests.

Best Practices

  • Start with domain naming that matches resource semantics
  • Keep templates stable, readable, and human-friendly
  • Encode parameters safely in URIs and test parsing with edge cases
  • Document hierarchies and MIME type mappings alongside templates
  • Version URI schemes and plan migrations with deprecation notes

Example Use Cases

  • db://{database}/tables/{table}
  • db://{database}/schema
  • db://{database}/query/{queryId}
  • file:///{path}
  • git://{repo}/branches/{branch}/files/{path}

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers