Abstract base class for defining resources in the MCPServer SDK.
# Source: https://github.com/modelcontextprotocol/python-sdk | License: MIT | Copyright 2024 Anthropic, PBC
# Provided via justclaw.it.com; keep this notice with the code.
"""Base classes and interfaces for MCPServer resources."""
import abc
from typing import Any
from mcp_types import Annotations, Icon
from pydantic import (
BaseModel,
ConfigDict,
Field,
ValidationInfo,
field_validator,
)
class Resource(BaseModel, abc.ABC):
"""Base class for all resources."""
model_config = ConfigDict(validate_default=True, extra="forbid")
uri: str = Field(default=..., description="URI of the resource")
name: str | None = Field(description="Name of the resource", default=None)
title: str | None = Field(description="Human-readable title of the resource", defaul
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key