sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
PaddlePaddle/PaddleOCR:tests/testing_utils.py
from pathlib import Path TEST_DATA_DIR = Path(__file__).parent / "test_files" def check_simple_inference_result(result, *, expected_length=1): assert result is not None assert isinstance(result, list) assert len(result) == expected_length for res in result: assert isinstance(res, dict) def ...
{ "repo_id": "PaddlePaddle/PaddleOCR", "file_path": "tests/testing_utils.py", "license": "Apache License 2.0", "lines": 28, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/deprecated/test_tool_injection_middleware.py
"""Tests for deprecated PromptToolMiddleware and ResourceToolMiddleware.""" import pytest from inline_snapshot import snapshot from mcp.types import TextContent from mcp.types import Tool as SDKTool from fastmcp import FastMCP from fastmcp.client import Client from fastmcp.client.client import CallToolResult from fas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/deprecated/test_tool_injection_middleware.py", "license": "Apache License 2.0", "lines": 211, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/experimental/transforms/test_code_mode_discovery.py
import json from typing import Any from mcp.types import TextContent from fastmcp import FastMCP from fastmcp.experimental.transforms.code_mode import ( CodeMode, GetTags, ListTools, Search, _ensure_async, ) from fastmcp.tools.tool import ToolResult def _unwrap_result(result: ToolResult) -> Any:...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/experimental/transforms/test_code_mode_discovery.py", "license": "Apache License 2.0", "lines": 456, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/client/sampling/handlers/google_genai.py
"""Google GenAI sampling handler with tool support for FastMCP 3.0.""" from collections.abc import Sequence from uuid import uuid4 try: from google.genai import Client as GoogleGenaiClient from google.genai.types import ( Candidate, Content, FunctionCall, FunctionCallingConfig,...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/client/sampling/handlers/google_genai.py", "license": "Apache License 2.0", "lines": 314, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/client/sampling/handlers/test_google_genai_handler.py
from unittest.mock import MagicMock import pytest try: from google.genai import Client as GoogleGenaiClient from google.genai.types import ( Candidate, FunctionCall, FunctionCallingConfigMode, GenerateContentResponse, ModelContent, Part, UserContent, ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/sampling/handlers/test_google_genai_handler.py", "license": "Apache License 2.0", "lines": 289, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/experimental/transforms/test_code_mode_serialization.py
from typing import Any import pytest from fastmcp import FastMCP from fastmcp.server.transforms.search.base import ( _schema_section, _schema_type, serialize_tools_for_output_markdown, ) # --------------------------------------------------------------------------- # _schema_type unit tests # ------------...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/experimental/transforms/test_code_mode_serialization.py", "license": "Apache License 2.0", "lines": 149, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/auth/propelauth_oauth/client.py
"""OAuth client example for connecting to PropelAuth-protected FastMCP servers. This example demonstrates how to connect to a PropelAuth OAuth-protected FastMCP server. To run: python client.py """ import asyncio from fastmcp.client import Client SERVER_URL = "http://127.0.0.1:8000/mcp" async def main(): ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/propelauth_oauth/client.py", "license": "Apache License 2.0", "lines": 30, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/propelauth_oauth/server.py
"""PropelAuth OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with PropelAuth OAuth. Required environment variables: - PROPELAUTH_AUTH_URL: Your PropelAuth Auth URL (from Backend Integration page) - PROPELAUTH_INTROSPECTION_CLIENT_ID: Introspection Client ID (from MCP > Req...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/propelauth_oauth/server.py", "license": "Apache License 2.0", "lines": 38, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/propelauth.py
"""PropelAuth authentication provider for FastMCP. Example: ```python from fastmcp import FastMCP from fastmcp.server.auth.providers.propelauth import PropelAuthProvider auth = PropelAuthProvider( auth_url="https://auth.yourdomain.com", introspection_client_id="your-client-id", ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/propelauth.py", "license": "Apache License 2.0", "lines": 200, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/providers/test_propelauth.py
"""Tests for PropelAuthProvider.""" from typing import cast from unittest.mock import AsyncMock import httpx import pytest from pydantic import SecretStr from fastmcp import Client, FastMCP from fastmcp.server.auth import AccessToken from fastmcp.server.auth.providers.introspection import IntrospectionTokenVerifier ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_propelauth.py", "license": "Apache License 2.0", "lines": 277, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_multi_auth.py
import httpx import pytest from pydantic import AnyHttpUrl from fastmcp import FastMCP from fastmcp.server.auth import MultiAuth, RemoteAuthProvider, TokenVerifier from fastmcp.server.auth.auth import AccessToken from fastmcp.server.auth.providers.jwt import StaticTokenVerifier class RaisingVerifier(TokenVerifier): ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_multi_auth.py", "license": "Apache License 2.0", "lines": 345, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/test_elicitation_enums.py
"""Tests for enum-based elicitation, multi-select, and default values.""" from dataclasses import dataclass from enum import Enum import pytest from pydantic import BaseModel, Field from fastmcp import Context, FastMCP from fastmcp.client.client import Client from fastmcp.client.elicitation import ElicitResult from ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/test_elicitation_enums.py", "license": "Apache License 2.0", "lines": 408, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/test_sampling_result_types.py
from mcp.types import TextContent from fastmcp import Client, Context, FastMCP from fastmcp.client.sampling import RequestContext, SamplingMessage, SamplingParams class TestSamplingResultType: """Tests for result_type parameter (structured output).""" async def test_result_type_creates_final_response_tool(s...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/test_sampling_result_types.py", "license": "Apache License 2.0", "lines": 367, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/test_sampling_tool_loop.py
from typing import cast from mcp.types import TextContent from fastmcp import Client, Context, FastMCP from fastmcp.client.sampling import RequestContext, SamplingMessage, SamplingParams from fastmcp.server.sampling import SamplingTool class TestAutomaticToolLoop: """Tests for automatic tool execution loop in c...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/test_sampling_tool_loop.py", "license": "Apache License 2.0", "lines": 659, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/resources/test_resource_template_query_params.py
import pytest from fastmcp.resources import ResourceTemplate class TestQueryParameterExtraction: """Test basic query parameter extraction from URIs.""" async def test_single_query_param(self): """Test resource template with single query parameter.""" def get_data(id: str, format: str = "jso...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/resources/test_resource_template_query_params.py", "license": "Apache License 2.0", "lines": 326, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/providers/test_azure_scopes.py
"""Tests for Azure provider scope handling, JWT verifier, and OBO integration.""" import pytest from key_value.aio.stores.memory import MemoryStore from fastmcp.server.auth.providers.azure import ( OIDC_SCOPES, AzureJWTVerifier, AzureProvider, ) from fastmcp.server.auth.providers.jwt import RSAKeyPair @...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_azure_scopes.py", "license": "Apache License 2.0", "lines": 592, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_cimd_validators.py
"""Unit tests for CIMD assertion validators, client manager, and redirect URI enforcement.""" from __future__ import annotations from unittest.mock import AsyncMock, patch import pytest from pydantic import AnyHttpUrl from fastmcp.server.auth.cimd import ( CIMDAssertionValidator, CIMDClientManager, CIMD...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_cimd_validators.py", "license": "Apache License 2.0", "lines": 578, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_jwt_provider_bearer.py
from collections.abc import AsyncGenerator from typing import Any import httpx import pytest from fastmcp import Client, FastMCP from fastmcp.client.auth.bearer import BearerAuth from fastmcp.server.auth.providers.jwt import JWTVerifier, RSAKeyPair from fastmcp.utilities.tests import run_server_async # Standard publ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_jwt_provider_bearer.py", "license": "Apache License 2.0", "lines": 509, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oauth_consent_page.py
"""Tests for OAuth Proxy consent page display, CSP policy, and consent binding cookie.""" import re import secrets import time from unittest.mock import Mock from urllib.parse import parse_qs, urlparse import pytest from key_value.aio.stores.memory import MemoryStore from mcp.server.auth.provider import Authorization...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oauth_consent_page.py", "license": "Apache License 2.0", "lines": 598, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oidc_proxy_token.py
"""Tests for OIDC Proxy verify_id_token functionality.""" from unittest.mock import patch import pytest from pydantic import AnyHttpUrl from fastmcp.server.auth.oauth_proxy.models import UpstreamTokenSet from fastmcp.server.auth.oidc_proxy import OIDCConfiguration, OIDCProxy from fastmcp.server.auth.providers.intros...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oidc_proxy_token.py", "license": "Apache License 2.0", "lines": 280, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/middleware/test_middleware_nested.py
from collections.abc import Callable from dataclasses import dataclass from typing import Any import mcp.types import pytest from fastmcp import Client, FastMCP from fastmcp.exceptions import ToolError from fastmcp.server.context import Context from fastmcp.server.middleware import CallNext, Middleware, MiddlewareCon...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_middleware_nested.py", "license": "Apache License 2.0", "lines": 534, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_auth_integration_errors.py
import base64 import hashlib import secrets import time from urllib.parse import parse_qs, urlparse import httpx import pytest from mcp.server.auth.provider import ( AccessToken, AuthorizationCode, AuthorizationParams, OAuthAuthorizationServerProvider, RefreshToken, construct_redirect_uri, ) fr...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_auth_integration_errors.py", "license": "Apache License 2.0", "lines": 452, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_dependencies_advanced.py
"""Advanced tests for dependency injection in FastMCP: context annotations, vendored DI, and auth dependencies.""" import inspect import mcp.types as mcp_types import pytest from fastmcp import FastMCP from fastmcp.client import Client from fastmcp.dependencies import CurrentContext from fastmcp.server.context impor...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_dependencies_advanced.py", "license": "Apache License 2.0", "lines": 216, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/openapi/test_circular_references.py
"""Tests for circular and self-referential schema serialization (Issues #1016, #1206, #3242).""" import httpx from fastmcp import FastMCP from fastmcp.utilities.openapi.models import ( ResponseInfo, ) from fastmcp.utilities.openapi.schemas import ( _replace_ref_with_defs, extract_output_schema_from_respon...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/openapi/test_circular_references.py", "license": "Apache License 2.0", "lines": 234, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/test_inspect_icons.py
"""Tests for icon extraction and formatting functions in inspect.py.""" import importlib.metadata from mcp.server.fastmcp import FastMCP as FastMCP1x import fastmcp from fastmcp import FastMCP from fastmcp.utilities.inspect import ( InspectFormat, format_fastmcp_info, format_info, format_mcp_info, ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/test_inspect_icons.py", "license": "Apache License 2.0", "lines": 399, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/apps/chart_server.py
"""Chart MCP App — interactive data visualizations with Prefab. Demonstrates `fastmcp[apps]` with Prefab chart components: - `BarChart` and `LineChart` for categorical and trend data - Multiple series, stacking, and curve styles - Layout composition with `Column`, `Heading`, and `Muted` - Custom text fallback via `Too...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/apps/chart_server.py", "license": "Apache License 2.0", "lines": 82, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/apps/datatable_server.py
"""DataTable MCP App — interactive, sortable data views with Prefab. Demonstrates `fastmcp[apps]` with Prefab UI components: - `app=True` for automatic renderer wiring - `PrefabApp` with `DataTable` for rich tabular views - Searchable, sortable, paginated tables - Layout composition with `Column`, `Heading`, `Text`, a...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/apps/datatable_server.py", "license": "Apache License 2.0", "lines": 149, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:examples/apps/patterns_server.py
"""Patterns showcase — every Prefab pattern from the docs in one server. A runnable collection of the patterns from https://gofastmcp.com/apps/patterns. Each tool demonstrates a different Prefab UI pattern: charts, tables, forms, status displays, conditional content, tabs, and accordions. Usage: uv run python pat...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/apps/patterns_server.py", "license": "Apache License 2.0", "lines": 415, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/test_apps_prefab.py
"""Tests for MCP Apps Phase 2 — Prefab integration. Covers ``convert_result`` for PrefabApp/Component, ``app=True`` auto-wiring, return-type inference, output-schema suppression, and end-to-end round trips. """ from __future__ import annotations from typing import Annotated from mcp.types import TextContent from pr...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/test_apps_prefab.py", "license": "Apache License 2.0", "lines": 332, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/code_mode/client.py
"""Example: Client using CodeMode to discover and chain tools. CodeMode exposes just two tools: `search` (keyword query) and `execute` (run Python code with `call_tool` available). This client demonstrates both: searching for tools, then chaining multiple calls in a single execute block — one round-trip instead of man...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/code_mode/client.py", "license": "Apache License 2.0", "lines": 122, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:examples/code_mode/server.py
"""Example: CodeMode transform — search and execute tools via code. CodeMode replaces the entire tool catalog with two meta-tools: `search` (keyword-based tool discovery) and `execute` (run Python code that chains tool calls in a sandbox). This dramatically reduces round-trips and context window usage when an LLM need...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/code_mode/server.py", "license": "Apache License 2.0", "lines": 58, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/experimental/transforms/code_mode.py
import importlib import json from collections.abc import Awaitable, Callable, Sequence from typing import Annotated, Any, Literal, Protocol from mcp.types import TextContent from pydantic import Field from fastmcp.exceptions import NotFoundError from fastmcp.server.context import Context from fastmcp.server.transform...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/experimental/transforms/code_mode.py", "license": "Apache License 2.0", "lines": 473, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/experimental/transforms/test_code_mode.py
import importlib import json from typing import Any import pytest from mcp.types import ImageContent, TextContent from fastmcp import Client, FastMCP from fastmcp.exceptions import ToolError from fastmcp.experimental.transforms.code_mode import ( CodeMode, GetSchemas, GetToolCatalog, MontySandboxProvi...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/experimental/transforms/test_code_mode.py", "license": "Apache License 2.0", "lines": 525, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/search/client_bm25.py
"""Example: Client using BM25 search to discover and call tools. BM25 search accepts natural language queries instead of regex patterns. This client shows how relevance ranking surfaces the best matches. Run with: uv run python examples/search/client_bm25.py """ import asyncio import json from typing import Any ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/search/client_bm25.py", "license": "Apache License 2.0", "lines": 132, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:examples/search/client_regex.py
"""Example: Client using regex search to discover and call tools. Regex search lets clients find tools by matching patterns against tool names and descriptions. Precise when you know what you're looking for. Run with: uv run python examples/search/client_regex.py """ import asyncio import json from typing import...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/search/client_regex.py", "license": "Apache License 2.0", "lines": 140, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:examples/search/server_bm25.py
"""Example: Search transforms with BM25 relevance ranking. BM25SearchTransform uses term-frequency/inverse-document-frequency scoring to rank tools by relevance to a natural language query. Unlike regex search (which requires the user to construct a pattern), BM25 handles queries like "work with text" or "do math" and...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/search/server_bm25.py", "license": "Apache License 2.0", "lines": 59, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/search/server_regex.py
"""Example: Search transforms with regex pattern matching. When a server has many tools, listing them all at once can overwhelm an LLM's context window. Search transforms collapse the full tool catalog behind a search interface — clients see only `search_tools` and `call_tool`, and discover the real tools on demand. ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/search/server_regex.py", "license": "Apache License 2.0", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/transforms/catalog.py
"""Base class for transforms that need to read the real component catalog. Some transforms replace ``list_tools()`` output with synthetic components (e.g. a search interface) while still needing access to the *real* (auth-filtered) catalog at call time. ``CatalogTransform`` provides the bypass machinery so subclasses...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/catalog.py", "license": "Apache License 2.0", "lines": 199, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/server/transforms/search/base.py
"""Base class for search transforms. Search transforms replace ``list_tools()`` output with a small set of synthetic tools — a search tool and a call-tool proxy — so LLMs can discover tools on demand instead of receiving the full catalog. All concrete search transforms (``RegexSearchTransform``, ``BM25SearchTransform...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/search/base.py", "license": "Apache License 2.0", "lines": 216, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/transforms/search/bm25.py
"""BM25-based search transform.""" import hashlib import math import re from collections.abc import Sequence from typing import Annotated, Any from fastmcp.server.context import Context from fastmcp.server.transforms.search.base import ( BaseSearchTransform, SearchResultSerializer, _extract_searchable_tex...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/search/bm25.py", "license": "Apache License 2.0", "lines": 120, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/transforms/search/regex.py
"""Regex-based search transform.""" import re from collections.abc import Sequence from typing import Annotated, Any from fastmcp.server.context import Context from fastmcp.server.transforms.search.base import ( BaseSearchTransform, _extract_searchable_text, ) from fastmcp.tools.tool import Tool class Regex...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/search/regex.py", "license": "Apache License 2.0", "lines": 44, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:tests/server/transforms/test_catalog.py
"""Tests for CatalogTransform base class.""" from __future__ import annotations import ast from collections.abc import Sequence from mcp.types import TextContent from fastmcp import FastMCP from fastmcp.server.context import Context from fastmcp.server.transforms import GetToolNext from fastmcp.server.transforms.ca...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/transforms/test_catalog.py", "license": "Apache License 2.0", "lines": 187, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/transforms/test_search.py
"""Tests for search transforms.""" from __future__ import annotations from collections.abc import Sequence from typing import Any from unittest.mock import MagicMock import mcp.types as mcp_types import pytest from mcp.types import TextContent from fastmcp import Client, FastMCP from fastmcp.server.context import C...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/transforms/test_search.py", "license": "Apache License 2.0", "lines": 395, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/openapi/test_propertynames_ref_rewrite.py
from fastmcp.utilities.openapi.schemas import _replace_ref_with_defs def test_replace_ref_with_defs_rewrites_propertyNames_ref(): """ Regression test for issue #3303. When using dict[StrEnum, Model], Pydantic generates: { "type": "object", "propertyNames": {"$ref": "#/com...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/openapi/test_propertynames_ref_rewrite.py", "license": "Apache License 2.0", "lines": 24, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/providers/test_http_client.py
"""Tests for http_client parameter on token verifiers. Verifies that all token verifiers accept an optional httpx.AsyncClient for connection pooling (issues #3287 and #3293). """ import time import httpx import pytest from pytest_httpx import HTTPXMock from fastmcp.server.auth.providers.introspection import Introsp...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_http_client.py", "license": "Apache License 2.0", "lines": 304, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:scripts/benchmark_imports.py
#!/usr/bin/env python """Benchmark import times for fastmcp and its dependency chain. Each measurement runs in a fresh subprocess so there's no shared module cache. Incremental costs are measured by pre-importing dependencies, so we can see what each module truly adds. Usage: uv run python scripts/benchmark_impor...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "scripts/benchmark_imports.py", "license": "Apache License 2.0", "lines": 189, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/sampling/test_prepare_tools.py
"""Tests for prepare_tools helper function.""" import pytest from fastmcp.server.sampling.run import prepare_tools from fastmcp.server.sampling.sampling_tool import SamplingTool from fastmcp.tools.function_tool import FunctionTool from fastmcp.tools.tool_transform import ArgTransform, TransformedTool class TestPrep...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/sampling/test_prepare_tools.py", "license": "Apache License 2.0", "lines": 80, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/elicitation.py
""" FastMCP Elicitation Example Demonstrates tools that ask users for input during execution. Try it with the CLI: fastmcp list examples/elicitation.py fastmcp call examples/elicitation.py greet fastmcp call examples/elicitation.py survey """ from dataclasses import dataclass from fastmcp import Contex...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/elicitation.py", "license": "Apache License 2.0", "lines": 33, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/task_elicitation.py
""" Background task elicitation demo. A background task (Docket) that pauses mid-execution to ask the user a question, waits for the answer, then resumes and finishes. Works with both in-memory and Redis backends: # In-memory (single process, no Redis needed) FASTMCP_DOCKET_URL=memory:// uv run python exampl...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/task_elicitation.py", "license": "Apache License 2.0", "lines": 57, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/cli/auth.py
"""Authentication-related CLI commands.""" import cyclopts from fastmcp.cli.cimd import cimd_app auth_app = cyclopts.App( name="auth", help="Authentication-related utilities and configuration.", ) # Nest CIMD commands under auth auth_app.command(cimd_app)
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/auth.py", "license": "Apache License 2.0", "lines": 9, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/cli/cimd.py
"""CIMD (Client ID Metadata Document) CLI commands.""" from __future__ import annotations import asyncio import json import sys from pathlib import Path from typing import Annotated import cyclopts from rich.console import Console from fastmcp.server.auth.cimd import ( CIMDFetcher, CIMDFetchError, CIMDV...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/cimd.py", "license": "Apache License 2.0", "lines": 189, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/client.py
"""Client-side CLI commands for querying and invoking MCP servers.""" import difflib import json import shlex import sys from pathlib import Path from typing import Annotated, Any, Literal import cyclopts import mcp.types from rich.console import Console from rich.markup import escape as escape_rich_markup from fast...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/client.py", "license": "Apache License 2.0", "lines": 827, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/discovery.py
"""Discover MCP servers configured in editor config files. Scans filesystem-readable config files from editors like Claude Desktop, Claude Code, Cursor, Gemini CLI, and Goose, as well as project-level ``mcp.json`` files. Each discovered server can be resolved by name (or ``source:name``) so the CLI can connect without...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/discovery.py", "license": "Apache License 2.0", "lines": 300, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/generate.py
"""Generate a standalone CLI script and agent skill from an MCP server.""" import keyword import re import sys import textwrap from pathlib import Path from typing import Annotated, Any from urllib.parse import urlparse import cyclopts import mcp.types import pydantic_core from mcp import McpError from rich.console i...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/generate.py", "license": "Apache License 2.0", "lines": 680, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/auth/cimd.py
"""CIMD (Client ID Metadata Document) support for FastMCP. .. warning:: **Beta Feature**: CIMD support is currently in beta. The API may change in future releases. Please report any issues you encounter. CIMD is a simpler alternative to Dynamic Client Registration where clients host a static JSON document at ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/cimd.py", "license": "Apache License 2.0", "lines": 671, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/auth/ssrf.py
"""SSRF-safe HTTP utilities for FastMCP. This module provides SSRF-protected HTTP fetching with: - DNS resolution and IP validation before requests - DNS pinning to prevent rebinding TOCTOU attacks - Support for both CIMD and JWKS fetches """ from __future__ import annotations import asyncio import ipaddress import ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/ssrf.py", "license": "Apache License 2.0", "lines": 285, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/middleware/dereference.py
"""Middleware that dereferences $ref in JSON schemas before sending to clients.""" from collections.abc import Sequence from typing import Any import mcp.types as mt from typing_extensions import override from fastmcp.resources.template import ResourceTemplate from fastmcp.server.middleware.middleware import CallNex...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/middleware/dereference.py", "license": "Apache License 2.0", "lines": 64, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/middleware/response_limiting.py
"""Response limiting middleware for controlling tool response sizes.""" from __future__ import annotations import logging import mcp.types as mt import pydantic_core from mcp.types import TextContent from fastmcp.tools.tool import ToolResult from .middleware import CallNext, Middleware, MiddlewareContext __all__ ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/middleware/response_limiting.py", "license": "Apache License 2.0", "lines": 100, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/tasks/elicitation.py
"""Background task elicitation support (SEP-1686). This module provides elicitation capabilities for background tasks running in Docket workers. Unlike regular MCP requests, background tasks don't have an active request context, so elicitation requires special handling: 1. Set task status to "input_required" via Redi...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/tasks/elicitation.py", "license": "Apache License 2.0", "lines": 298, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/tasks/notifications.py
"""Distributed notification queue for background task events (SEP-1686). Enables distributed Docket workers to send MCP notifications to clients without holding session references. Workers push to a Redis queue, the MCP server process subscribes and forwards to the client's session. Pattern: Fire-and-forward with ret...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/tasks/notifications.py", "license": "Apache License 2.0", "lines": 249, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/cli/test_cimd_cli.py
"""Tests for the CIMD CLI commands (create and validate).""" from __future__ import annotations import json from unittest.mock import AsyncMock, patch import pytest from pydantic import AnyHttpUrl from fastmcp.cli.cimd import create_command, validate_command from fastmcp.server.auth.cimd import CIMDDocument, CIMDFe...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_cimd_cli.py", "license": "Apache License 2.0", "lines": 183, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_client_commands.py
"""Tests for fastmcp list and fastmcp call CLI commands.""" import json from pathlib import Path from typing import Any from unittest.mock import patch import mcp.types import pytest from fastmcp import FastMCP from fastmcp.cli import client as client_module from fastmcp.cli.client import ( Client, _build_cl...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_client_commands.py", "license": "Apache License 2.0", "lines": 458, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_discovery.py
"""Tests for MCP server discovery and name-based resolution.""" import json from pathlib import Path from typing import Any import pytest import yaml from fastmcp.cli.client import _is_http_target, resolve_server_spec from fastmcp.cli.discovery import ( DiscoveredServer, _normalize_server_entry, _parse_m...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_discovery.py", "license": "Apache License 2.0", "lines": 548, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_generate_cli.py
"""Tests for fastmcp generate-cli command.""" import sys from pathlib import Path from typing import Any from unittest.mock import patch import mcp.types import pytest from fastmcp import FastMCP from fastmcp.cli import generate as generate_module from fastmcp.cli.client import Client from fastmcp.cli.generate impor...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_generate_cli.py", "license": "Apache License 2.0", "lines": 790, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/auth/test_oauth_cimd.py
"""Tests for CIMD (Client ID Metadata Document) support in the OAuth client.""" from __future__ import annotations import warnings import httpx import pytest from fastmcp.client.auth import OAuth from fastmcp.client.transports import StreamableHttpTransport from fastmcp.client.transports.sse import SSETransport VA...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/auth/test_oauth_cimd.py", "license": "Apache License 2.0", "lines": 135, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/auth/test_oauth_static_client.py
"""Tests for OAuth static client registration (pre-registered client_id/client_secret).""" from unittest.mock import patch import httpx import pytest from mcp.shared.auth import OAuthClientInformationFull from pydantic import AnyUrl from fastmcp.client import Client from fastmcp.client.auth import OAuth from fastmcp...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/auth/test_oauth_static_client.py", "license": "Apache License 2.0", "lines": 226, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_cimd.py
"""Unit tests for CIMD (Client ID Metadata Document) functionality.""" from __future__ import annotations import time from unittest.mock import patch import pytest from pydantic import AnyHttpUrl, ValidationError from fastmcp.server.auth.cimd import ( CIMDDocument, CIMDFetcher, CIMDFetchError, CIMDV...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_cimd.py", "license": "Apache License 2.0", "lines": 473, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_ssrf_protection.py
"""Tests for SSRF-safe HTTP utilities. This module tests the ssrf.py module which provides SSRF-protected HTTP fetching. """ from unittest.mock import AsyncMock, MagicMock, patch import httpx import pytest from fastmcp.server.auth.ssrf import ( SSRFError, SSRFFetchError, is_ip_allowed, ssrf_safe_fet...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_ssrf_protection.py", "license": "Apache License 2.0", "lines": 357, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/middleware/test_dereference.py
"""Tests for DereferenceRefsMiddleware.""" from enum import Enum import pydantic from fastmcp import Client, FastMCP class Color(Enum): RED = "red" GREEN = "green" BLUE = "blue" class PaintRequest(pydantic.BaseModel): color: Color opacity: float = 1.0 class TestDereferenceRefsMiddleware: ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_dereference.py", "license": "Apache License 2.0", "lines": 98, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/middleware/test_response_limiting.py
"""Tests for ResponseLimitingMiddleware.""" import pytest from mcp.types import ImageContent, TextContent from fastmcp import Client, FastMCP from fastmcp.server.middleware.response_limiting import ResponseLimitingMiddleware from fastmcp.tools.tool import ToolResult class TestResponseLimitingMiddleware: """Test...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_response_limiting.py", "license": "Apache License 2.0", "lines": 124, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/tasks/test_context_background_task.py
"""Tests for Context background task support (SEP-1686). Tests Context API surface (unit) and background task elicitation (integration). Integration tests use Client(mcp) with the real memory:// Docket backend — no mocking of Redis, Docket, or session internals. """ import asyncio from typing import cast import pyte...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/tasks/test_context_background_task.py", "license": "Apache License 2.0", "lines": 374, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/tasks/test_notifications.py
"""Tests for distributed notification queue (SEP-1686). Integration tests verify that the notification queue works end-to-end using Client(mcp) with the real memory:// Docket backend. No mocking of Redis, sessions, or Docket internals. """ import asyncio import mcp.types as mcp_types from fastmcp import FastMCP fro...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/tasks/test_notifications.py", "license": "Apache License 2.0", "lines": 119, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/tasks/test_task_elicitation_relay.py
"""Tests for background task elicitation relay (notifications.py). The relay bridges distributed background tasks to clients via the standard MCP elicitation/create protocol. When a worker calls ctx.elicit(), the notification subscriber detects the input_required notification and sends an elicitation/create request to...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/tasks/test_task_elicitation_relay.py", "license": "Apache License 2.0", "lines": 154, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/test_json_schema_generation.py
"""Tests for JSON schema generation from FastMCP BaseModel classes. Validates that callable fields are properly excluded from generated schemas using SkipJsonSchema annotations. """ from fastmcp.prompts.function_prompt import FunctionPrompt from fastmcp.resources.function_resource import FunctionResource from fastmcp...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/test_json_schema_generation.py", "license": "Apache License 2.0", "lines": 171, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/apps/qr_server/qr_server.py
"""QR Code MCP App Server — generates QR codes with an interactive view UI. Demonstrates MCP Apps with FastMCP: - Tool linked to a ui:// resource via AppConfig - HTML resource with CSP metadata for CDN-loaded dependencies - Embedded HTML using the @modelcontextprotocol/ext-apps JS SDK - ImageContent return type for bi...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/apps/qr_server/qr_server.py", "license": "Apache License 2.0", "lines": 141, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/cli/install/goose.py
"""Goose integration for FastMCP install using Cyclopts.""" import re import sys from pathlib import Path from typing import Annotated from urllib.parse import quote import cyclopts from rich import print from fastmcp.utilities.logging import get_logger from .shared import open_deeplink, process_common_args logger...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/goose.py", "license": "Apache License 2.0", "lines": 172, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/install/stdio.py
"""Stdio command generation for FastMCP install using Cyclopts.""" import builtins import shlex import sys from pathlib import Path from typing import Annotated import cyclopts import pyperclip from rich import print as rich_print from fastmcp.utilities.logging import get_logger from fastmcp.utilities.mcp_server_con...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/stdio.py", "license": "Apache License 2.0", "lines": 137, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/apps.py
"""MCP Apps support — extension negotiation and typed UI metadata models. Provides constants and Pydantic models for the MCP Apps extension (io.modelcontextprotocol/ui), enabling tools and resources to carry UI metadata for clients that support interactive app rendering. """ from __future__ import annotations from t...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/apps.py", "license": "Apache License 2.0", "lines": 114, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/cli/test_goose.py
from pathlib import Path from unittest.mock import patch from urllib.parse import parse_qs, unquote, urlparse import pytest from fastmcp.cli.install.goose import ( _build_uvx_command, _slugify, generate_goose_deeplink, goose_command, install_goose, ) class TestSlugify: def test_simple_name(s...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_goose.py", "license": "Apache License 2.0", "lines": 262, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/test_apps.py
"""Tests for MCP Apps Phase 1 — SDK compatibility. Covers app config models, tool/resource registration with ``app=``, extension negotiation, and the ``Context.client_supports_extension`` method. """ from __future__ import annotations from typing import Any import pytest from fastmcp import Client, FastMCP from fa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/test_apps.py", "license": "Apache License 2.0", "lines": 437, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/test_auth.py
"""Tests for authentication utility helpers.""" import base64 import json import pytest from fastmcp.utilities.auth import ( decode_jwt_header, decode_jwt_payload, parse_scopes, ) def create_jwt(header: dict, payload: dict, signature: bytes = b"fake-sig") -> str: """Create a test JWT token.""" ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/test_auth.py", "license": "Apache License 2.0", "lines": 136, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/skills/download_skills.py
"""Example: Downloading skills from an MCP server. This example shows how to use the skills client utilities to discover and download skills from any MCP server that exposes them via SkillsProvider. Run this script: uv run python examples/skills/download_skills.py This example creates an in-memory server with sa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/skills/download_skills.py", "license": "Apache License 2.0", "lines": 64, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/utilities/skills.py
"""Client utilities for discovering and downloading skills from MCP servers.""" from __future__ import annotations import base64 import json from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING import mcp.types if TYPE_CHECKING: from fastmcp.client import Client @datacla...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/utilities/skills.py", "license": "Apache License 2.0", "lines": 197, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/utilities/test_skills.py
"""Tests for skills client utilities.""" from __future__ import annotations from pathlib import Path import pytest from fastmcp import Client, FastMCP from fastmcp.server.providers.skills import SkillsDirectoryProvider from fastmcp.utilities.skills import ( SkillFile, SkillManifest, SkillSummary, do...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/test_skills.py", "license": "Apache License 2.0", "lines": 205, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/skills/client.py
"""Example: Skills Client This example shows how to discover and download skills from a skills server. Run this client (it starts its own server internally): uv run python examples/skills/client.py """ import asyncio import json from pathlib import Path from fastmcp import Client from fastmcp.server.providers.s...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/skills/client.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/skills/server.py
"""Example: Skills Provider Server This example shows how to expose agent skills as MCP resources. Skills can be discovered, browsed, and downloaded by any MCP client. Run this server: uv run python examples/skills/server.py Then use the client example to interact with it: uv run python examples/skills/clien...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/skills/server.py", "license": "Apache License 2.0", "lines": 37, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/providers/skills/_common.py
"""Shared utilities and data structures for skills providers.""" from __future__ import annotations import hashlib import re from dataclasses import dataclass, field from pathlib import Path from typing import Any @dataclass class SkillFileInfo: """Information about a file within a skill.""" path: str # R...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/providers/skills/_common.py", "license": "Apache License 2.0", "lines": 82, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/providers/skills/claude_provider.py
"""Claude-specific skills provider for Claude Code skills.""" from __future__ import annotations from pathlib import Path from typing import Literal from fastmcp.server.providers.skills.directory_provider import SkillsDirectoryProvider class ClaudeSkillsProvider(SkillsDirectoryProvider): """Provider for Claude...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/providers/skills/claude_provider.py", "license": "Apache License 2.0", "lines": 33, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/server/providers/skills/directory_provider.py
"""Directory scanning provider for discovering multiple skills.""" from __future__ import annotations from collections.abc import Sequence from pathlib import Path from typing import Literal from fastmcp.resources.resource import Resource from fastmcp.resources.template import ResourceTemplate from fastmcp.server.pr...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/providers/skills/directory_provider.py", "license": "Apache License 2.0", "lines": 126, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/providers/skills/skill_provider.py
"""Basic skill provider for handling a single skill folder.""" from __future__ import annotations import json import mimetypes from collections.abc import Sequence from pathlib import Path from typing import Any, Literal, cast from pydantic import AnyUrl from fastmcp.resources.resource import Resource, ResourceResu...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/providers/skills/skill_provider.py", "license": "Apache License 2.0", "lines": 369, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/providers/skills/vendor_providers.py
"""Vendor-specific skills providers for various AI coding platforms.""" from __future__ import annotations from pathlib import Path from typing import Literal from fastmcp.server.providers.skills.directory_provider import SkillsDirectoryProvider class CursorSkillsProvider(SkillsDirectoryProvider): """Cursor sk...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/providers/skills/vendor_providers.py", "license": "Apache License 2.0", "lines": 109, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:tests/server/providers/test_skills_provider.py
"""Tests for SkillProvider, SkillsDirectoryProvider, and ClaudeSkillsProvider.""" import json from pathlib import Path import pytest from mcp.types import TextResourceContents from pydantic import AnyUrl from fastmcp import Client, FastMCP from fastmcp.server.providers.skills import ( ClaudeSkillsProvider, S...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/providers/test_skills_provider.py", "license": "Apache License 2.0", "lines": 533, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/providers/test_skills_vendor_providers.py
"""Tests for vendor-specific skills providers.""" from __future__ import annotations from pathlib import Path from fastmcp.server.providers.skills import ( ClaudeSkillsProvider, CodexSkillsProvider, CopilotSkillsProvider, CursorSkillsProvider, GeminiSkillsProvider, GooseSkillsProvider, Op...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/providers/test_skills_vendor_providers.py", "license": "Apache License 2.0", "lines": 165, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/prompts_as_tools/client.py
"""Example: Client using prompts-as-tools. This client demonstrates calling the list_prompts and get_prompt tools generated by the PromptsAsTools transform. Run with: uv run python examples/prompts_as_tools/client.py """ import asyncio import json from fastmcp.client import Client async def main(): # Conn...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/prompts_as_tools/client.py", "license": "Apache License 2.0", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/prompts_as_tools/server.py
"""Example: Expose prompts as tools using PromptsAsTools transform. This example shows how to use PromptsAsTools to make prompts accessible to clients that only support tools (not the prompts protocol). Run with: uv run python examples/prompts_as_tools/server.py """ from fastmcp import FastMCP from fastmcp.serve...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/prompts_as_tools/server.py", "license": "Apache License 2.0", "lines": 62, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/server/transforms/prompts_as_tools.py
"""Transform that exposes prompts as tools. This transform generates tools for listing and getting prompts, enabling clients that only support tools to access prompt functionality. Example: ```python from fastmcp import FastMCP from fastmcp.server.transforms import PromptsAsTools mcp = FastMCP("Serve...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/prompts_as_tools.py", "license": "Apache License 2.0", "lines": 137, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/transforms/test_prompts_as_tools.py
"""Tests for PromptsAsTools transform.""" import json import pytest from fastmcp import FastMCP from fastmcp.client import Client from fastmcp.server.transforms import PromptsAsTools class TestPromptsAsToolsBasic: """Test basic PromptsAsTools functionality.""" async def test_adds_list_prompts_tool(self): ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/transforms/test_prompts_as_tools.py", "license": "Apache License 2.0", "lines": 155, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/resources_as_tools/client.py
"""Example: Client using resources-as-tools. This client demonstrates calling the list_resources and read_resource tools generated by the ResourcesAsTools transform. Run with: uv run python examples/resources_as_tools/client.py """ import asyncio import json from fastmcp.client import Client async def main():...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/resources_as_tools/client.py", "license": "Apache License 2.0", "lines": 41, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/resources_as_tools/server.py
"""Example: Expose resources as tools using ResourcesAsTools transform. This example shows how to use ResourcesAsTools to make resources accessible to clients that only support tools (not the resources protocol). Run with: uv run python examples/resources_as_tools/server.py """ from fastmcp import FastMCP from f...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/resources_as_tools/server.py", "license": "Apache License 2.0", "lines": 48, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/server/transforms/resources_as_tools.py
"""Transform that exposes resources as tools. This transform generates tools for listing and reading resources, enabling clients that only support tools to access resource functionality. Example: ```python from fastmcp import FastMCP from fastmcp.server.transforms import ResourcesAsTools mcp = FastMC...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/transforms/resources_as_tools.py", "license": "Apache License 2.0", "lines": 151, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex