sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
PrefectHQ/fastmcp:tests/server/auth/providers/test_discord.py
"""Tests for Discord OAuth provider.""" from unittest.mock import AsyncMock, MagicMock, patch import pytest from key_value.aio.stores.memory import MemoryStore from fastmcp.server.auth.providers.discord import DiscordProvider, DiscordTokenVerifier @pytest.fixture def memory_storage() -> MemoryStore: """Provide...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_discord.py", "license": "Apache License 2.0", "lines": 104, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/http/test_stale_access_token.py
""" Test for issue #1863: get_access_token() returns stale token after OAuth refresh. This test demonstrates the bug where auth_context_var holds a stale token, but the current HTTP request (via request_ctx) has a fresh token. The test should FAIL with the current implementation and PASS after the fix. """ from unit...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/http/test_stale_access_token.py", "license": "Apache License 2.0", "lines": 132, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/oci.py
"""OCI OIDC provider for FastMCP. The pull request for the provider is submitted to fastmcp. This module provides OIDC Implementation to integrate MCP servers with OCI. You only need OCI Identity Domain's discovery URL, client ID, client secret, and base URL. Post Authentication, you get OCI IAM domain access token....
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/oci.py", "license": "Apache License 2.0", "lines": 141, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:examples/testing_demo/server.py
""" FastMCP Testing Demo Server A simple MCP server demonstrating tools, resources, and prompts with comprehensive test coverage. """ from fastmcp import FastMCP # Create server mcp = FastMCP("Testing Demo") # Tools @mcp.tool def add(a: int, b: int) -> int: """Add two numbers together""" return a + b @mc...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/testing_demo/server.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:examples/testing_demo/tests/test_server.py
""" Tests for the Testing Demo server. Demonstrates pytest-asyncio patterns, fixtures, and testing best practices. """ import pytest from dirty_equals import IsStr from fastmcp.client import Client @pytest.fixture async def client(): """ Client fixture for testing. Uses async context manager and yield...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/testing_demo/tests/test_server.py", "license": "Apache License 2.0", "lines": 118, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/transports/test_transports.py
from ssl import VerifyMode import httpx from fastmcp.client.auth.oauth import OAuth from fastmcp.client.transports import SSETransport, StreamableHttpTransport async def test_oauth_uses_same_client_as_transport_streamable_http(): transport = StreamableHttpTransport( "https://some.fake.url/", htt...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/transports/test_transports.py", "license": "Apache License 2.0", "lines": 34, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/tool_result_echo.py
""" FastMCP Echo Server with Metadata Demonstrates how to return metadata alongside content and structured data. The meta field can include execution details, versioning, or other information that clients may find useful. """ import time from dataclasses import dataclass from fastmcp import FastMCP from fastmcp.tool...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/tool_result_echo.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:src/fastmcp/server/auth/providers/debug.py
"""Debug token verifier for testing and special cases. This module provides a flexible token verifier that delegates validation to a custom callable. Useful for testing, development, or scenarios where standard verification isn't possible (like opaque tokens without introspection). Example: ```python from fas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/debug.py", "license": "Apache License 2.0", "lines": 89, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/test_debug_verifier.py
"""Unit tests for DebugTokenVerifier.""" import re from fastmcp.server.auth.providers.debug import DebugTokenVerifier class TestDebugTokenVerifier: """Test DebugTokenVerifier initialization and validation.""" def test_init_defaults(self): """Test initialization with default parameters.""" v...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_debug_verifier.py", "license": "Apache License 2.0", "lines": 120, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/middleware/tool_injection.py
"""A middleware for injecting tools into the MCP server context.""" import warnings from collections.abc import Sequence from logging import Logger from typing import Annotated, Any import mcp.types from mcp.types import Prompt from pydantic import AnyUrl from typing_extensions import override import fastmcp from fa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/middleware/tool_injection.py", "license": "Apache License 2.0", "lines": 106, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:tests/server/middleware/test_tool_injection.py
"""Tests for tool injection middleware.""" import math import pytest from inline_snapshot import snapshot from mcp.types import Tool as SDKTool from fastmcp import FastMCP from fastmcp.client import Client from fastmcp.client.client import CallToolResult from fastmcp.client.transports import FastMCPTransport from fa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_tool_injection.py", "license": "Apache License 2.0", "lines": 215, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/handlers/authorize.py
"""Enhanced authorization handler with improved error responses. This module provides an enhanced authorization handler that wraps the MCP SDK's AuthorizationHandler to provide better error messages when clients attempt to authorize with unregistered client IDs. The enhancement adds: - Content negotiation: HTML for b...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/handlers/authorize.py", "license": "Apache License 2.0", "lines": 278, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/server/auth/middleware.py
"""Enhanced authentication middleware with better error messages. This module provides enhanced versions of MCP SDK authentication middleware that return more helpful error messages for developers troubleshooting authentication issues. """ from __future__ import annotations import json from mcp.server.auth.middlewa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/middleware.py", "license": "Apache License 2.0", "lines": 77, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:tests/server/auth/test_enhanced_error_responses.py
"""Tests for enhanced OAuth error responses. This test suite covers: 1. Enhanced authorization handler (HTML and JSON error pages) 2. Enhanced middleware (better error messages) 3. Content negotiation 4. Server branding in error pages """ import pytest from mcp.shared.auth import OAuthClientInformationFull from pydan...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_enhanced_error_responses.py", "license": "Apache License 2.0", "lines": 304, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_icons.py
"""Tests for icon support across all MCP object types.""" from mcp.types import Icon from fastmcp import Client, FastMCP from fastmcp.prompts import Message, Prompt from fastmcp.resources import Resource from fastmcp.resources.template import ResourceTemplate from fastmcp.tools import Tool class TestServerIcons: ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_icons.py", "license": "Apache License 2.0", "lines": 262, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/jwt_issuer.py
"""JWT token issuance and verification for FastMCP OAuth Proxy. This module implements the token factory pattern for OAuth proxies, where the proxy issues its own JWT tokens to clients instead of forwarding upstream provider tokens. This maintains proper OAuth 2.0 token audience boundaries. """ from __future__ import...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/jwt_issuer.py", "license": "Apache License 2.0", "lines": 195, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/test_jwt_issuer.py
"""Unit tests for JWT issuer and token encryption.""" import base64 import time import pytest from authlib.jose.errors import JoseError from fastmcp.server.auth.jwt_issuer import ( JWTIssuer, derive_jwt_key, ) class TestKeyDerivation: """Tests for HKDF key derivation functions.""" def test_derive_...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_jwt_issuer.py", "license": "Apache License 2.0", "lines": 240, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oauth_mounting.py
"""Tests for OAuth .well-known routes when FastMCP apps are mounted in parent ASGI apps. This test file validates the fix for issue #2077 where .well-known/oauth-protected-resource returns 404 at root level when a FastMCP app is mounted under a path prefix. The fix uses MCP SDK 1.17+ which implements RFC 9728 path-sc...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oauth_mounting.py", "license": "Apache License 2.0", "lines": 318, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/middleware/caching.py
"""A middleware for response caching.""" import hashlib from collections.abc import Sequence from logging import Logger from typing import Any, TypedDict import mcp.types import pydantic_core from key_value.aio.adapters.pydantic import PydanticAdapter from key_value.aio.protocols.key_value import AsyncKeyValue from k...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/middleware/caching.py", "license": "Apache License 2.0", "lines": 429, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/middleware/test_caching.py
"""Tests for response caching middleware.""" import sys import tempfile import warnings from pathlib import Path from unittest.mock import AsyncMock, MagicMock import mcp.types import pytest from inline_snapshot import snapshot from key_value.aio.stores.filetree import ( FileTreeStore, FileTreeV1CollectionSan...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_caching.py", "license": "Apache License 2.0", "lines": 550, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:scripts/auto_close_needs_mre.py
#!/usr/bin/env python # /// script # requires-python = ">=3.10" # dependencies = [ # "httpx", # ] # /// """ Auto-close issues that need MRE (Minimal Reproducible Example). This script runs on a schedule to automatically close issues that have been marked as "needs MRE" and haven't received activity from the issue ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "scripts/auto_close_needs_mre.py", "license": "Apache License 2.0", "lines": 325, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/introspection.py
"""OAuth 2.0 Token Introspection (RFC 7662) provider for FastMCP. This module provides token verification for opaque tokens using the OAuth 2.0 Token Introspection protocol defined in RFC 7662. It allows FastMCP servers to validate tokens issued by authorization servers that don't use JWT format. Example: ```pyth...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/introspection.py", "license": "Apache License 2.0", "lines": 332, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/providers/test_introspection.py
"""Tests for OAuth 2.0 Token Introspection verifier (RFC 7662).""" import base64 import time from typing import Any import pytest from pytest_httpx import HTTPXMock from fastmcp.server.auth.providers.introspection import ( IntrospectionTokenVerifier, ) class TestIntrospectionTokenVerifier: """Test core tok...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_introspection.py", "license": "Apache License 2.0", "lines": 827, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/client/test_oauth_callback_xss.py
"""Comprehensive XSS protection tests for OAuth callback HTML rendering.""" import pytest from fastmcp.client.oauth_callback import create_callback_html from fastmcp.utilities.ui import ( create_detail_box, create_info_box, create_page, create_status_message, ) def test_ui_create_page_escapes_title(...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/test_oauth_callback_xss.py", "license": "Apache License 2.0", "lines": 120, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_input_validation.py
""" Tests for input validation behavior with strict_input_validation setting. This module tests the difference between strict JSON schema validation (when strict_input_validation=True) and Pydantic-based coercion (when strict_input_validation=False, the default). """ import json import pytest from mcp.types import T...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_input_validation.py", "license": "Apache License 2.0", "lines": 292, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_server_lifespan.py
"""Tests for server_lifespan and session_lifespan behavior.""" from collections.abc import AsyncIterator from contextlib import asynccontextmanager from typing import Any import pytest from fastmcp import Client, FastMCP from fastmcp.server.context import Context from fastmcp.server.lifespan import ContextManagerLif...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_server_lifespan.py", "license": "Apache License 2.0", "lines": 429, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/utilities/ui.py
""" Shared UI utilities for FastMCP HTML pages. This module provides reusable HTML/CSS components for OAuth callbacks, consent pages, and other user-facing interfaces. """ from __future__ import annotations import html from starlette.responses import HTMLResponse # FastMCP branding FASTMCP_LOGO_URL = "https://gofa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/utilities/ui.py", "license": "Apache License 2.0", "lines": 530, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/test_oauth_consent_flow.py
"""Tests for OAuth Proxy consent flow with server-side storage. This test suite verifies: 1. OAuth transactions are stored in server-side storage (not in-memory) 2. Authorization codes are stored in server-side storage 3. Consent flow redirects correctly through /consent endpoint 4. CSRF protection works with cookies ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oauth_consent_flow.py", "license": "Apache License 2.0", "lines": 557, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/supabase.py
"""Supabase authentication provider for FastMCP. This module provides SupabaseProvider - a complete authentication solution that integrates with Supabase Auth's JWT verification, supporting Dynamic Client Registration (DCR) for seamless MCP client authentication. """ from __future__ import annotations from typing im...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/supabase.py", "license": "Apache License 2.0", "lines": 153, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/providers/test_supabase.py
"""Tests for Supabase Auth provider.""" from collections.abc import Generator import httpx import pytest from fastmcp import Client, FastMCP from fastmcp.client.transports import StreamableHttpTransport from fastmcp.server.auth.providers.jwt import JWTVerifier from fastmcp.server.auth.providers.supabase import Supab...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_supabase.py", "license": "Apache License 2.0", "lines": 171, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/middleware/test_initialization_middleware.py
"""Tests for middleware support during initialization.""" from collections.abc import Sequence from typing import Any import mcp.types as mt import pytest from mcp import McpError from mcp.types import ErrorData, TextContent from fastmcp import Client, FastMCP from fastmcp.server.middleware import CallNext, Middlewa...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/middleware/test_initialization_middleware.py", "license": "Apache License 2.0", "lines": 338, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/auth/authkit_dcr/client.py
"""OAuth client example for connecting to FastMCP servers. This example demonstrates how to connect to an OAuth-protected FastMCP server. To run: python client.py """ import asyncio from fastmcp.client import Client from fastmcp.client.auth import OAuth SERVER_URL = "http://127.0.0.1:8000/mcp" async def main...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/authkit_dcr/client.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/authkit_dcr/server.py
"""AuthKit DCR server example for FastMCP. This example demonstrates how to protect a FastMCP server with AuthKit DCR. Required environment variables: - FASTMCP_SERVER_AUTH_AUTHKITPROVIDER_AUTHKIT_DOMAIN: Your AuthKit domain (e.g., "https://your-app.authkit.app") To run: python server.py """ import os from fas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/authkit_dcr/server.py", "license": "Apache License 2.0", "lines": 21, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/scalekit_oauth/client.py
"""OAuth client example for connecting to Scalekit-protected FastMCP servers. This example demonstrates how to connect to a Scalekit 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(): try...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/scalekit_oauth/client.py", "license": "Apache License 2.0", "lines": 28, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/scalekit_oauth/server.py
"""Scalekit OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with Scalekit OAuth. Required environment variables: - SCALEKIT_ENVIRONMENT_URL: Your Scalekit environment URL (e.g., "https://your-env.scalekit.com") - SCALEKIT_RESOURCE_ID: Your Scalekit resource ID Optional: - ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/scalekit_oauth/server.py", "license": "Apache License 2.0", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/scalekit.py
"""Scalekit authentication provider for FastMCP. This module provides ScalekitProvider - a complete authentication solution that integrates with Scalekit's OAuth 2.1 and OpenID Connect services, supporting Resource Server authentication for seamless MCP client authentication. """ from __future__ import annotations i...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/scalekit.py", "license": "Apache License 2.0", "lines": 183, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/providers/test_scalekit.py
"""Tests for Scalekit OAuth provider.""" import httpx import pytest from fastmcp import Client, FastMCP from fastmcp.client.transports import StreamableHttpTransport from fastmcp.server.auth.providers.jwt import JWTVerifier from fastmcp.server.auth.providers.scalekit import ScalekitProvider from fastmcp.utilities.tes...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_scalekit.py", "license": "Apache License 2.0", "lines": 175, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/auth/aws_oauth/client.py
"""OAuth client example for connecting to FastMCP servers. This example demonstrates how to connect to an OAuth-protected FastMCP server. To run: python client.py """ import asyncio from fastmcp.client import Client SERVER_URL = "http://localhost:8000/mcp" async def main(): try: async with Client...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/aws_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/aws_oauth/server.py
"""AWS Cognito OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with AWS Cognito. Required environment variables: - FASTMCP_SERVER_AUTH_AWS_COGNITO_USER_POOL_ID: Your AWS Cognito User Pool ID - FASTMCP_SERVER_AUTH_AWS_COGNITO_AWS_REGION: Your AWS region (optional, defaults t...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/aws_oauth/server.py", "license": "Apache License 2.0", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/aws.py
"""AWS Cognito OAuth provider for FastMCP. This module provides a complete AWS Cognito OAuth integration that's ready to use with a user pool ID, domain prefix, client ID and client secret. It handles all the complexity of AWS Cognito's OAuth flow, token validation, and user management. Example: ```python fro...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/aws.py", "license": "Apache License 2.0", "lines": 168, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/providers/test_aws.py
"""Unit tests for AWS Cognito OAuth provider.""" from contextlib import contextmanager from unittest.mock import patch from fastmcp.server.auth.providers.aws import ( AWSCognitoProvider, ) @contextmanager def mock_cognito_oidc_discovery(): """Context manager to mock AWS Cognito OIDC discovery endpoint.""" ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_aws.py", "license": "Apache License 2.0", "lines": 116, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oauth_proxy_storage.py
"""Tests for OAuth proxy with persistent storage.""" import tempfile import warnings from collections.abc import AsyncGenerator from pathlib import Path from unittest.mock import AsyncMock, Mock import pytest from inline_snapshot import snapshot from key_value.aio.protocols import AsyncKeyValue from key_value.aio.sto...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oauth_proxy_storage.py", "license": "Apache License 2.0", "lines": 185, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/descope.py
"""Descope authentication provider for FastMCP. This module provides DescopeProvider - a complete authentication solution that integrates with Descope's OAuth 2.1 and OpenID Connect services, supporting Dynamic Client Registration (DCR) for seamless MCP client authentication. """ from __future__ import annotations f...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/descope.py", "license": "Apache License 2.0", "lines": 178, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/providers/test_descope.py
"""Tests for Descope OAuth provider.""" import os from unittest.mock import patch import httpx import pytest from fastmcp import Client, FastMCP from fastmcp.client.transports import StreamableHttpTransport from fastmcp.server.auth.providers.descope import DescopeProvider from fastmcp.server.auth.providers.jwt impor...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_descope.py", "license": "Apache License 2.0", "lines": 199, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_log_level.py
"""Test log_level parameter support in FastMCP server.""" import asyncio from unittest.mock import AsyncMock, patch from fastmcp import FastMCP class TestLogLevelParameter: """Test that log_level parameter is properly accepted by run methods.""" async def test_run_stdio_accepts_log_level(self): """...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_log_level.py", "license": "Apache License 2.0", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/oidc_proxy.py
"""OIDC Proxy Provider for FastMCP. This provider acts as a transparent proxy to an upstream OIDC compliant Authorization Server. It leverages the OAuthProxy class to handle Dynamic Client Registration and forwarding of all OAuth flows. This implementation is based on: OpenID Connect Discovery 1.0 - https://openi...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/oidc_proxy.py", "license": "Apache License 2.0", "lines": 394, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/auth0.py
"""Auth0 OAuth provider for FastMCP. This module provides a complete Auth0 integration that's ready to use with just the configuration URL, client ID, client secret, audience, and base URL. Example: ```python from fastmcp import FastMCP from fastmcp.server.auth.providers.auth0 import Auth0Provider # ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/auth0.py", "license": "Apache License 2.0", "lines": 108, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/providers/test_auth0.py
"""Unit tests for Auth0 OAuth provider.""" from unittest.mock import patch import pytest from fastmcp.server.auth.oidc_proxy import OIDCConfiguration from fastmcp.server.auth.providers.auth0 import Auth0Provider from fastmcp.server.auth.providers.jwt import JWTVerifier TEST_CONFIG_URL = "https://example.com/.well-k...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_auth0.py", "license": "Apache License 2.0", "lines": 80, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oidc_proxy.py
"""Comprehensive tests for OIDC Proxy Provider functionality.""" import json from unittest.mock import MagicMock, patch import pytest from httpx import Response from pydantic import AnyHttpUrl from fastmcp.server.auth.oidc_proxy import OIDCConfiguration, OIDCProxy from fastmcp.server.auth.providers.introspection imp...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oidc_proxy.py", "license": "Apache License 2.0", "lines": 755, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/cli/install/gemini_cli.py
"""Gemini CLI integration for FastMCP install using Cyclopts.""" import shutil import subprocess import sys from pathlib import Path from typing import Annotated import cyclopts from rich import print from fastmcp.utilities.logging import get_logger from fastmcp.utilities.mcp_server_config.v1.environments.uv import ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/gemini_cli.py", "license": "Apache License 2.0", "lines": 209, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/auth/test_auth_provider.py
import re import httpx import pytest from pydantic import AnyHttpUrl from fastmcp import FastMCP from fastmcp.server.auth import RemoteAuthProvider from fastmcp.server.auth.providers.jwt import StaticTokenVerifier class TestAuthProviderBase: """Test suite for base AuthProvider behaviors that apply to all auth p...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_auth_provider.py", "license": "Apache License 2.0", "lines": 87, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/utilities/mcp_server_config/v1/environments/base.py
from abc import ABC, abstractmethod from pathlib import Path from pydantic import BaseModel, Field class Environment(BaseModel, ABC): """Base class for environment configuration.""" type: str = Field(description="Environment type identifier") @abstractmethod def build_command(self, command: list[st...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/utilities/mcp_server_config/v1/environments/base.py", "license": "Apache License 2.0", "lines": 20, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:src/fastmcp/utilities/mcp_server_config/v1/environments/uv.py
import shutil import subprocess from pathlib import Path from typing import Literal from pydantic import Field from fastmcp.utilities.logging import get_logger from fastmcp.utilities.mcp_server_config.v1.environments.base import Environment logger = get_logger("cli.config") class UVEnvironment(Environment): ""...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/utilities/mcp_server_config/v1/environments/uv.py", "license": "Apache License 2.0", "lines": 234, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/utilities/auth.py
"""Authentication utility helpers.""" from __future__ import annotations import base64 import json from typing import Any def _decode_jwt_part(token: str, part_index: int) -> dict[str, Any]: """Decode a JWT part (header or payload) without signature verification. Args: token: JWT token string (head...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/utilities/auth.py", "license": "Apache License 2.0", "lines": 68, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/cli/test_project_prepare.py
"""Tests for the fastmcp project prepare command.""" import subprocess from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch import pytest from fastmcp.utilities.mcp_server_config import MCPServerConfig from fastmcp.utilities.mcp_server_config.v1.environments.uv import UVEnvironment from fas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_project_prepare.py", "license": "Apache License 2.0", "lines": 241, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/redirect_validation.py
"""Utilities for validating client redirect URIs in OAuth flows. This module provides secure redirect URI validation with wildcard support, protecting against userinfo-based bypass attacks like http://localhost@evil.com. """ import fnmatch from urllib.parse import urlparse from pydantic import AnyUrl def _parse_ho...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/redirect_validation.py", "license": "Apache License 2.0", "lines": 160, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/cli/test_server_args.py
"""Test server argument passing functionality.""" from pathlib import Path import pytest from fastmcp.utilities.mcp_server_config import MCPServerConfig from fastmcp.utilities.mcp_server_config.v1.sources.filesystem import FileSystemSource class TestServerArguments: """Test passing arguments to servers.""" ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_server_args.py", "license": "Apache License 2.0", "lines": 96, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_with_argv.py
"""Test the with_argv context manager.""" import sys from unittest.mock import patch import pytest from fastmcp.cli.cli import with_argv class TestWithArgv: """Test the with_argv context manager.""" def test_with_argv_replaces_args(self): """Test that with_argv properly replaces sys.argv.""" ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_with_argv.py", "license": "Apache License 2.0", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_oauth_proxy_redirect_validation.py
"""Tests for OAuth proxy redirect URI validation.""" from unittest.mock import patch import pytest from key_value.aio.stores.memory import MemoryStore from mcp.shared.auth import InvalidRedirectUriError from pydantic import AnyHttpUrl, AnyUrl from fastmcp.server.auth.auth import TokenVerifier from fastmcp.server.aut...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_oauth_proxy_redirect_validation.py", "license": "Apache License 2.0", "lines": 339, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_redirect_validation.py
"""Tests for redirect URI validation in OAuth flows.""" from pydantic import AnyUrl from fastmcp.server.auth.redirect_validation import ( DEFAULT_LOCALHOST_PATTERNS, matches_allowed_pattern, validate_redirect_uri, ) class TestMatchesAllowedPattern: """Test wildcard pattern matching for redirect URIs...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_redirect_validation.py", "license": "Apache License 2.0", "lines": 164, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/test_cli.py
"""Tests for CLI utility functions.""" from pathlib import Path from fastmcp.utilities.mcp_server_config.v1.environments.uv import UVEnvironment class TestEnvironmentBuildUVRunCommand: """Test the Environment.build_uv_run_command() method.""" def test_build_uv_run_command_basic(self): """Test build...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/test_cli.py", "license": "Apache License 2.0", "lines": 173, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/auth/azure_oauth/client.py
"""OAuth client example for connecting to FastMCP servers. This example demonstrates how to connect to an 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(): try: async with Client...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/azure_oauth/client.py", "license": "Apache License 2.0", "lines": 22, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/azure_oauth/server.py
"""Azure (Microsoft Entra) OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with Azure/Microsoft OAuth. Required environment variables: - AZURE_CLIENT_ID: Your Azure application (client) ID - AZURE_CLIENT_SECRET: Your Azure client secret - AZURE_TENANT_ID: Tenant ID Option...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/azure_oauth/server.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/auth/workos_oauth/server.py
"""WorkOS OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with WorkOS OAuth. Required environment variables: - WORKOS_CLIENT_ID: Your WorkOS Connect application client ID - WORKOS_CLIENT_SECRET: Your WorkOS Connect application client secret - WORKOS_AUTHKIT_DOMAIN: Your Aut...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/workos_oauth/server.py", "license": "Apache License 2.0", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/azure.py
"""Azure (Microsoft Entra) OAuth provider for FastMCP. This provider implements Azure/Microsoft Entra ID OAuth authentication using the OAuth Proxy pattern for non-DCR OAuth flows. """ from __future__ import annotations import hashlib from collections import OrderedDict from typing import TYPE_CHECKING, Any, cast i...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/azure.py", "license": "Apache License 2.0", "lines": 607, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:tests/server/auth/providers/test_azure.py
"""Tests for Azure (Microsoft Entra) OAuth provider.""" from urllib.parse import parse_qs, urlparse import pytest from key_value.aio.stores.memory import MemoryStore from mcp.server.auth.provider import AuthorizationParams from mcp.shared.auth import OAuthClientInformationFull from pydantic import AnyUrl from fastmc...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_azure.py", "license": "Apache License 2.0", "lines": 656, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/providers/test_google.py
"""Tests for Google OAuth provider.""" import pytest from key_value.aio.stores.memory import MemoryStore from fastmcp.server.auth.providers.google import GoogleProvider @pytest.fixture def memory_storage() -> MemoryStore: """Provide a MemoryStore for tests to avoid SQLite initialization on Windows.""" retur...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_google.py", "license": "Apache License 2.0", "lines": 116, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/providers/test_workos.py
"""Tests for WorkOS OAuth provider.""" from urllib.parse import urlparse import httpx import pytest from key_value.aio.stores.memory import MemoryStore from pytest_httpx import HTTPXMock from fastmcp import Client, FastMCP from fastmcp.client.transports import StreamableHttpTransport from fastmcp.server.auth.provide...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_workos.py", "license": "Apache License 2.0", "lines": 184, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/fastmcp_config/server.py
"""Example FastMCP server for demonstrating fastmcp.json configuration.""" from fastmcp import FastMCP # Create the FastMCP server instance mcp = FastMCP("Config Example Server") @mcp.tool def echo(text: str) -> str: """Echo the provided text back to the user.""" return f"You said: {text}" @mcp.tool def a...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/fastmcp_config/server.py", "license": "Apache License 2.0", "lines": 27, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
PrefectHQ/fastmcp:examples/fastmcp_config_demo/server.py
""" Example server demonstrating fastmcp.json configuration. This server previously would have used the deprecated dependencies parameter: mcp = FastMCP("Demo Server", dependencies=["pyautogui", "Pillow"]) Now dependencies are declared in fastmcp.json alongside this file. """ import io from fastmcp import FastM...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/fastmcp_config_demo/server.py", "license": "Apache License 2.0", "lines": 49, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:tests/cli/test_config.py
"""Tests for FastMCP configuration file support with nested structure.""" import json import os from pathlib import Path import pytest from pydantic import ValidationError from fastmcp.utilities.mcp_server_config import ( Deployment, MCPServerConfig, ) from fastmcp.utilities.mcp_server_config.v1.environments...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_config.py", "license": "Apache License 2.0", "lines": 386, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_run_config.py
"""Integration tests for FastMCP configuration with run command.""" import json import os from pathlib import Path import pytest from fastmcp.cli.run import load_mcp_server_config from fastmcp.utilities.mcp_server_config import ( Deployment, MCPServerConfig, ) from fastmcp.utilities.mcp_server_config.v1.envi...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_run_config.py", "license": "Apache License 2.0", "lines": 224, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:examples/auth/github_oauth/client.py
"""OAuth client example for connecting to FastMCP servers. This example demonstrates how to connect to an OAuth-protected FastMCP server. To run: python client.py """ import asyncio from fastmcp.client import Client, OAuth SERVER_URL = "http://localhost:8000/mcp" async def main(): try: async with...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/github_oauth/client.py", "license": "Apache License 2.0", "lines": 22, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/github_oauth/server.py
"""GitHub OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with GitHub OAuth. Required environment variables: - FASTMCP_SERVER_AUTH_GITHUB_CLIENT_ID: Your GitHub OAuth app client ID - FASTMCP_SERVER_AUTH_GITHUB_CLIENT_SECRET: Your GitHub OAuth app client secret To run: ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/github_oauth/server.py", "license": "Apache License 2.0", "lines": 24, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:examples/auth/google_oauth/server.py
"""Google OAuth server example for FastMCP. This example demonstrates how to protect a FastMCP server with Google OAuth. Required environment variables: - FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_ID: Your Google OAuth client ID - FASTMCP_SERVER_AUTH_GOOGLE_CLIENT_SECRET: Your Google OAuth client secret To run: python s...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "examples/auth/google_oauth/server.py", "license": "Apache License 2.0", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/github.py
"""GitHub OAuth provider for FastMCP. This module provides a complete GitHub OAuth integration that's ready to use with just a client ID and client secret. It handles all the complexity of GitHub's OAuth flow, token validation, and user management. Example: ```python from fastmcp import FastMCP from fastm...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/github.py", "license": "Apache License 2.0", "lines": 223, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/google.py
"""Google OAuth provider for FastMCP. This module provides a complete Google OAuth integration that's ready to use with just a client ID and client secret. It handles all the complexity of Google's OAuth flow, token validation, and user management. Example: ```python from fastmcp import FastMCP from fastm...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/google.py", "license": "Apache License 2.0", "lines": 258, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/integration_tests/auth/test_github_provider_integration.py
"""Integration tests for GitHub OAuth Provider. Tests the complete GitHub OAuth flow using HeadlessOAuth to bypass browser interaction. This test requires a GitHub OAuth app to be created at https://github.com/settings/developers with the following configuration: - Redirect URL: http://127.0.0.1:9100/auth/callback - ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/integration_tests/auth/test_github_provider_integration.py", "license": "Apache License 2.0", "lines": 314, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/providers/test_github.py
"""Unit tests for GitHub OAuth provider.""" from unittest.mock import MagicMock, patch import pytest from key_value.aio.stores.memory import MemoryStore from fastmcp.server.auth.providers.github import ( GitHubProvider, GitHubTokenVerifier, ) @pytest.fixture def memory_storage() -> MemoryStore: """Prov...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/providers/test_github.py", "license": "Apache License 2.0", "lines": 110, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:scripts/auto_close_duplicates.py
#!/usr/bin/env python # /// script # requires-python = ">=3.10" # dependencies = [ # "httpx", # ] # /// """ Auto-close duplicate GitHub issues. This script runs on a schedule to automatically close issues that have been marked as duplicates and haven't received any preventing activity. """ import os from dataclas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "scripts/auto_close_duplicates.py", "license": "Apache License 2.0", "lines": 296, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/server/test_streamable_http_no_redirect.py
"""Test that streamable HTTP routes avoid 307 redirects.""" import httpx import pytest from starlette.routing import Route from fastmcp import FastMCP @pytest.mark.parametrize( "server_path", ["/mcp", "/mcp/"], ) def test_streamable_http_route_structure(server_path: str): """Test that streamable HTTP ro...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_streamable_http_no_redirect.py", "license": "Apache License 2.0", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/test_components.py
"""Tests for fastmcp.utilities.components module.""" import warnings import pytest from pydantic import ValidationError from fastmcp.prompts.prompt import Prompt from fastmcp.resources.resource import Resource from fastmcp.resources.template import ResourceTemplate from fastmcp.tools.tool import Tool from fastmcp.ut...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/test_components.py", "license": "Apache License 2.0", "lines": 358, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/auth/test_remote_auth_provider.py
import httpx import pytest from pydantic import AnyHttpUrl from fastmcp import FastMCP from fastmcp.server.auth import RemoteAuthProvider from fastmcp.server.auth.providers.jwt import StaticTokenVerifier @pytest.fixture def test_tokens(): """Standard test tokens fixture for all auth tests.""" return { ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/auth/test_remote_auth_provider.py", "license": "Apache License 2.0", "lines": 455, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/server/auth/providers/workos.py
"""WorkOS authentication providers for FastMCP. This module provides two WorkOS authentication strategies: 1. WorkOSProvider - OAuth proxy for WorkOS Connect applications (non-DCR) 2. AuthKitProvider - DCR-compliant provider for WorkOS AuthKit Choose based on your WorkOS setup and authentication requirements. """ f...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/server/auth/providers/workos.py", "license": "Apache License 2.0", "lines": 335, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:tests/client/auth/test_oauth_client.py
from unittest.mock import patch from urllib.parse import urlparse import httpx import pytest from mcp.types import TextResourceContents from fastmcp.client import Client from fastmcp.client.auth import OAuth from fastmcp.client.transports import StreamableHttpTransport from fastmcp.server.auth.auth import ClientRegis...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/auth/test_oauth_client.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/http/test_http_auth_middleware.py
import pytest from mcp.server.auth.middleware.bearer_auth import RequireAuthMiddleware from starlette.routing import Route from starlette.testclient import TestClient from fastmcp.server import FastMCP from fastmcp.server.auth.providers.jwt import JWTVerifier, RSAKeyPair from fastmcp.server.http import create_streamab...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/http/test_http_auth_middleware.py", "license": "Apache License 2.0", "lines": 80, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/resources/test_resource_template_meta.py
from fastmcp.resources import ResourceTemplate class TestResourceTemplateMeta: """Test ResourceTemplate meta functionality.""" def test_template_meta_parameter(self): """Test that meta parameter is properly handled.""" def template_func(param: str) -> str: return f"Result: {param...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/resources/test_resource_template_meta.py", "license": "Apache License 2.0", "lines": 19, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/utilities/openapi/test_nullable_fields.py
"""Tests for nullable field handling in OpenAPI schemas.""" import pytest from jsonschema import ValidationError, validate from fastmcp.utilities.openapi.json_schema_converter import ( convert_openapi_schema_to_json_schema, ) class TestHandleNullableFields: """Test conversion of OpenAPI nullable fields to J...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/utilities/openapi/test_nullable_fields.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/transports/test_uv_transport.py
import inspect import sys import tempfile from pathlib import Path import pytest import fastmcp from fastmcp.client import Client from fastmcp.client.client import CallToolResult from fastmcp.client.transports import StdioTransport, UvStdioTransport # Detect if running from dev install to use local source instead of...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/client/transports/test_uv_transport.py", "license": "Apache License 2.0", "lines": 100, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/tools/test_tool_future_annotations.py
from __future__ import annotations from typing import Annotated, Any, Literal, cast import mcp.types from pydantic import Field from fastmcp import Context, FastMCP from fastmcp.client import Client from fastmcp.tools.tool import ToolResult from fastmcp.utilities.types import Image fastmcp_server = FastMCP() @fas...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/tools/test_tool_future_annotations.py", "license": "Apache License 2.0", "lines": 143, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/server/test_tool_transformation.py
import httpx from fastmcp import FastMCP from fastmcp.client import Client from fastmcp.server.transforms import ToolTransform from fastmcp.tools.tool_transform import ( ArgTransformConfig, ToolTransformConfig, ) async def test_tool_transformation_via_layer(): """Test that tool transformations work via a...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/server/test_tool_transformation.py", "license": "Apache License 2.0", "lines": 219, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/integration_tests/test_github_mcp_remote.py
import json import os import pytest from mcp import McpError from mcp.types import TextContent, Tool from fastmcp import Client from fastmcp.client import StreamableHttpTransport from fastmcp.client.auth.bearer import BearerAuth GITHUB_REMOTE_MCP_URL = "https://api.githubcopilot.com/mcp/" HEADER_AUTHORIZATION = "Au...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/integration_tests/test_github_mcp_remote.py", "license": "Apache License 2.0", "lines": 105, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_install.py
from pathlib import Path from fastmcp.cli.install import install_app from fastmcp.cli.install.stdio import install_stdio class TestInstallApp: """Test the install subapp.""" def test_install_app_exists(self): """Test that the install app is properly configured.""" # install_app.name is a tup...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_install.py", "license": "Apache License 2.0", "lines": 372, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_shared.py
from fastmcp.cli.cli import _parse_env_var class TestEnvVarParsing: """Test environment variable parsing functionality.""" def test_parse_env_var_simple(self): """Test parsing simple environment variable.""" key, value = _parse_env_var("API_KEY=secret123") assert key == "API_KEY" ...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_shared.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_cursor.py
import base64 import json from pathlib import Path from unittest.mock import Mock, patch import pytest from fastmcp.cli.install.cursor import ( cursor_command, generate_cursor_deeplink, install_cursor, install_cursor_workspace, open_deeplink, ) from fastmcp.mcp_config import StdioMCPServer class...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_cursor.py", "license": "Apache License 2.0", "lines": 361, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:tests/cli/test_cli.py
import subprocess from pathlib import Path from unittest.mock import Mock, patch import pytest from fastmcp.cli.cli import _parse_env_var, app class TestMainCLI: """Test the main CLI application.""" def test_app_exists(self): """Test that the main app is properly configured.""" # app.name i...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "tests/cli/test_cli.py", "license": "Apache License 2.0", "lines": 535, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
PrefectHQ/fastmcp:src/fastmcp/cli/install/shared.py
"""Shared utilities for install commands.""" import json import os import subprocess import sys from pathlib import Path from urllib.parse import urlparse from dotenv import dotenv_values from pydantic import ValidationError from rich import print from fastmcp.utilities.logging import get_logger from fastmcp.utiliti...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/shared.py", "license": "Apache License 2.0", "lines": 150, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/install/claude_code.py
"""Claude Code integration for FastMCP install using Cyclopts.""" import shutil import subprocess import sys from pathlib import Path from typing import Annotated import cyclopts from rich import print from fastmcp.utilities.logging import get_logger from fastmcp.utilities.mcp_server_config.v1.environments.uv import...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/claude_code.py", "license": "Apache License 2.0", "lines": 211, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/install/claude_desktop.py
"""Claude Desktop integration for FastMCP install using Cyclopts.""" import os import sys from pathlib import Path from typing import Annotated import cyclopts from rich import print from fastmcp.mcp_config import StdioMCPServer, update_config_file from fastmcp.utilities.logging import get_logger from fastmcp.utilit...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/claude_desktop.py", "license": "Apache License 2.0", "lines": 205, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
PrefectHQ/fastmcp:src/fastmcp/cli/install/cursor.py
"""Cursor integration for FastMCP install using Cyclopts.""" import base64 import sys from pathlib import Path from typing import Annotated from urllib.parse import quote import cyclopts from rich import print from fastmcp.mcp_config import StdioMCPServer, update_config_file from fastmcp.utilities.logging import get...
{ "repo_id": "PrefectHQ/fastmcp", "file_path": "src/fastmcp/cli/install/cursor.py", "license": "Apache License 2.0", "lines": 279, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex