sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
mlflow/mlflow:mlflow/utils/env_pack.py | import shutil
import subprocess
import sys
import tarfile
import tempfile
from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import Path
from typing import Generator, Literal
import yaml
from mlflow.artifacts import download_artifacts
from mlflow.exceptions import MlflowException
fro... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/utils/env_pack.py",
"license": "Apache License 2.0",
"lines": 180,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/utils/test_env_pack.py | import subprocess
import sys
import tarfile
import venv
from pathlib import Path
from unittest import mock
import pytest
import yaml
from mlflow.exceptions import MlflowException
from mlflow.utils import env_pack
from mlflow.utils.databricks_utils import DatabricksRuntimeVersion
from mlflow.utils.env_pack import EnvP... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/utils/test_env_pack.py",
"license": "Apache License 2.0",
"lines": 377,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/pyspark/optuna/study.py | import datetime
import logging
import tempfile
import traceback
from collections.abc import Callable, Iterable
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import optuna
import pandas as pd
from optuna import exceptions, pruners, samplers, storages
from optuna.study import Study
fr... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/pyspark/optuna/study.py",
"license": "Apache License 2.0",
"lines": 290,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/pyspark/optuna/test_study.py | import logging
import os
import numpy as np
import pyspark
import pytest
from optuna.samplers import TPESampler
from packaging.version import Version
import mlflow
from mlflow.exceptions import ExecutionException
from mlflow.pyspark.optuna.study import MlflowSparkStudy
from tests.optuna.test_storage import setup_sto... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/pyspark/optuna/test_study.py",
"license": "Apache License 2.0",
"lines": 159,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/test_mlflow_version_comp.py | import os
import subprocess
import sys
import uuid
from pathlib import Path
import numpy as np
import sklearn
from pyspark.sql import SparkSession
from sklearn.linear_model import LinearRegression
import mlflow
from mlflow.models import Model
def check_load(model_uri: str) -> None:
Model.load(model_uri)
mod... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/test_mlflow_version_comp.py",
"license": "Apache License 2.0",
"lines": 192,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/store/_unity_catalog/registry/prompt_info.py | """
Internal PromptInfo entity for Unity Catalog prompt operations.
This is an implementation detail for the Unity Catalog store and should not be
considered part of the public MLflow API.
"""
class PromptInfo:
"""
Internal entity for prompt information from Unity Catalog. This represents
prompt metadata... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/store/_unity_catalog/registry/prompt_info.py",
"license": "Apache License 2.0",
"lines": 60,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/store/_unity_catalog/registry/test_uc_prompt_utils.py | import json
from mlflow.entities.model_registry.prompt import Prompt
from mlflow.entities.model_registry.prompt_version import PromptVersion
from mlflow.prompt.constants import (
PROMPT_MODEL_CONFIG_TAG_KEY,
PROMPT_TYPE_TAG_KEY,
PROMPT_TYPE_TEXT,
RESPONSE_FORMAT_TAG_KEY,
)
from mlflow.protos.unity_cata... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/store/_unity_catalog/registry/test_uc_prompt_utils.py",
"license": "Apache License 2.0",
"lines": 184,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/genai/optimize/types.py | import multiprocessing
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Callable
from mlflow.entities import Feedback, Trace
from mlflow.entities.model_registry import PromptVersion
from mlflow.utils.annotations import deprecated, experimental
if TYPE_CHECKING:
from mlflow.genai.opt... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/optimize/types.py",
"license": "Apache License 2.0",
"lines": 130,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
mlflow/mlflow:mlflow/genai/optimize/util.py | from __future__ import annotations
import functools
from contextlib import contextmanager, nullcontext
from typing import TYPE_CHECKING, Any, Callable
from pydantic import BaseModel, create_model
from mlflow.entities import Trace
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers import Scorer
f... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/optimize/util.py",
"license": "Apache License 2.0",
"lines": 184,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/genai/optimize/test_util.py | from typing import Any, Union
import pytest
from pydantic import BaseModel
from mlflow.entities.assessment import Feedback
from mlflow.exceptions import MlflowException
from mlflow.genai.judges import CategoricalRating
from mlflow.genai.optimize.util import (
create_metric_from_scorers,
infer_type_from_value,... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/genai/optimize/test_util.py",
"license": "Apache License 2.0",
"lines": 186,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/genai/datasets/evaluation_dataset.py | from typing import TYPE_CHECKING, Any
from mlflow.data import Dataset
from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin
from mlflow.entities.evaluation_dataset import EvaluationDataset as _EntityEvaluationDataset
from mlflow.genai.datasets.databricks_evaluation_dataset_source import (
Data... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/datasets/evaluation_dataset.py",
"license": "Apache License 2.0",
"lines": 237,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:mlflow/autogen/chat.py | import logging
from typing import TYPE_CHECKING, Union
from opentelemetry.sdk.trace import Span
from mlflow.tracing.utils import set_span_chat_tools
from mlflow.types.chat import ChatTool
if TYPE_CHECKING:
from autogen_core.tools import BaseTool, ToolSchema
_logger = logging.getLogger(__name__)
def log_tools(... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/autogen/chat.py",
"license": "Apache License 2.0",
"lines": 28,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/ag2/test_ag2_autolog.py | import contextlib
import time
from unittest.mock import patch
import pytest
from autogen import ConversableAgent, GroupChat, GroupChatManager, UserProxyAgent, io
from openai import APIConnectionError
from openai.types.chat import ChatCompletion
from openai.types.chat.chat_completion import ChatCompletionMessage, Choic... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/ag2/test_ag2_autolog.py",
"license": "Apache License 2.0",
"lines": 335,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/tracing/utils/truncation.py | import json
from functools import lru_cache
from typing import Any
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.tracing.constant import (
TRACE_REQUEST_RESPONSE_PREVIEW_MAX_LENGTH_DBX,
TRACE_REQUEST_RESPONSE_PREVIEW_MAX_LENGTH_OSS,
)
from mlflow.... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/tracing/utils/truncation.py",
"license": "Apache License 2.0",
"lines": 102,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/tracing/utils/test_truncation.py | import json
from unittest.mock import patch
import pytest
from mlflow.entities.trace_data import TraceData
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.tracing.utils.truncation import _get_trunc... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/tracing/utils/test_truncation.py",
"license": "Apache License 2.0",
"lines": 212,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/genai/test_genai_import_without_agent_sdk.py | from unittest.mock import patch
import pytest
from mlflow.genai.datasets import create_dataset, delete_dataset, get_dataset
from mlflow.genai.scorers import (
delete_scorer,
get_scorer,
list_scorers,
)
from mlflow.genai.scorers.base import Scorer
# Test `mlflow.genai` namespace
def test_mlflow_genai_sta... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/genai/test_genai_import_without_agent_sdk.py",
"license": "Apache License 2.0",
"lines": 65,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/genai/utils/data_validation.py | import inspect
import logging
from typing import Any, Callable
from mlflow.exceptions import MlflowException
from mlflow.tracing.provider import trace_disabled
_logger = logging.getLogger(__name__)
def check_model_prediction(predict_fn: Callable[..., Any], sample_input: Any):
"""
Validate if the predict fun... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/utils/data_validation.py",
"license": "Apache License 2.0",
"lines": 117,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/genai/utils/test_data_validation.py | import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.genai.utils.data_validation import check_model_prediction
from tests.tracing.helper import get_traces
def _extract_code_example(e: MlflowException) -> str:
"""Extract the code example from the exception message."""
return ... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/genai/utils/test_data_validation.py",
"license": "Apache License 2.0",
"lines": 156,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/langgraph/sample_code/langgraph_with_autolog.py | from dataclasses import dataclass
from langchain.tools import tool
from langgraph.graph import END, StateGraph
import mlflow
mlflow.langchain.autolog()
@dataclass
class OverallState:
name: str = "LangChain" # add whatever fields you need
@tool
def my_tool():
"""
Called as the very first node.
Si... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/langgraph/sample_code/langgraph_with_autolog.py",
"license": "Apache License 2.0",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/langchain/sample_code/workflow.py | import json
import os
from typing import Any, Sequence
from langchain_core.language_models import LanguageModelLike
from langchain_core.messages import AIMessage, ToolCall
from langchain_core.outputs import ChatGeneration, ChatResult
from langchain_core.runnables import RunnableConfig, RunnableLambda
from langchain_co... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/langchain/sample_code/workflow.py",
"license": "Apache License 2.0",
"lines": 97,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/genai/scorers/validation.py | import importlib
import logging
from collections import defaultdict
from typing import Any, Callable
from mlflow.exceptions import MlflowException
from mlflow.genai.scorers.base import AggregationFunc, Scorer
from mlflow.genai.scorers.builtin_scorers import (
BuiltInScorer,
MissingColumnsException,
get_all... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/scorers/validation.py",
"license": "Apache License 2.0",
"lines": 170,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/genai/scorers/test_validation.py | from unittest import mock
import pandas as pd
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.genai.evaluation.utils import _convert_to_eval_set
from mlflow.genai.scorers.base import Scorer, scorer
from mlflow.genai.scorers.builtin_scorers import (
Correctness,
Expectatio... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/genai/scorers/test_validation.py",
"license": "Apache License 2.0",
"lines": 197,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/models/evaluation/deprecated.py | import functools
import warnings
from mlflow.models.evaluation import evaluate as model_evaluate
@functools.wraps(model_evaluate)
def evaluate(*args, **kwargs):
warnings.warn(
"The `mlflow.evaluate` API has been deprecated as of MLflow 3.0.0. "
"Please use these new alternatives:\n\n"
" -... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/models/evaluation/deprecated.py",
"license": "Apache License 2.0",
"lines": 16,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/evaluate/test_deprecated.py | import warnings
from contextlib import contextmanager
from unittest.mock import patch
import pandas as pd
import pytest
import mlflow
_TEST_DATA = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]})
@pytest.mark.parametrize("tracking_uri", ["databricks", "http://localhost:5000"])
def test_global_evaluate_warn_in_tracki... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/evaluate/test_deprecated.py",
"license": "Apache License 2.0",
"lines": 31,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/genai/evaluation/constant.py | class AgentEvaluationReserverKey:
"""
Expectation column names that are used by Agent Evaluation.
Ref: https://docs.databricks.com/aws/en/generative-ai/agent-evaluation/evaluation-schema
"""
EXPECTED_RESPONSE = "expected_response"
EXPECTED_RETRIEVED_CONTEXT = "expected_retrieved_context"
EX... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/genai/evaluation/constant.py",
"license": "Apache License 2.0",
"lines": 39,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/entities/test_trace_info_v2.py | import pytest
from google.protobuf.duration_pb2 import Duration
from google.protobuf.timestamp_pb2 import Timestamp
from mlflow.entities.trace_info_v2 import TraceInfoV2
from mlflow.entities.trace_status import TraceStatus
from mlflow.protos.service_pb2 import TraceInfo as ProtoTraceInfo
from mlflow.protos.service_pb2... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/entities/test_trace_info_v2.py",
"license": "Apache License 2.0",
"lines": 157,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/tracing/utils/environment.py | import logging
import os
from functools import lru_cache
from mlflow.tracking.context.git_context import GitRunContext
from mlflow.tracking.context.registry import resolve_tags
from mlflow.utils.databricks_utils import is_in_databricks_notebook
from mlflow.utils.git_utils import get_git_branch, get_git_commit, get_git... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/tracing/utils/environment.py",
"license": "Apache License 2.0",
"lines": 46,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/tracing/utils/test_environment.py | from unittest import mock
import pytest
from mlflow.tracing.utils.environment import resolve_env_metadata
from mlflow.utils.mlflow_tags import (
MLFLOW_DATABRICKS_NOTEBOOK_ID,
MLFLOW_DATABRICKS_NOTEBOOK_PATH,
MLFLOW_GIT_BRANCH,
MLFLOW_GIT_COMMIT,
MLFLOW_GIT_REPO_URL,
MLFLOW_SOURCE_NAME,
ML... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/tracing/utils/test_environment.py",
"license": "Apache License 2.0",
"lines": 53,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/entities/trace_info_v2.py | from dataclasses import asdict, dataclass, field
from typing import Any
from mlflow.entities._mlflow_object import _MlflowObject
from mlflow.entities.assessment import Assessment
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_status ... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/entities/trace_info_v2.py",
"license": "Apache License 2.0",
"lines": 136,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:examples/pydanticai/tracing.py | """
This is an example for leveraging MLflow's auto tracing capabilities for Pydantic AI.
Most codes are from https://ai.pydantic.dev/examples/bank-support/.
"""
import mlflow
import mlflow.pydantic_ai
mlflow.set_tracking_uri("http://localhost:5000")
mlflow.set_experiment("Pydantic AI Example")
mlflow.pydantic_ai.aut... | {
"repo_id": "mlflow/mlflow",
"file_path": "examples/pydanticai/tracing.py",
"license": "Apache License 2.0",
"lines": 64,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:mlflow/pydantic_ai/autolog.py | import contextvars
import inspect
import logging
from contextlib import asynccontextmanager
from dataclasses import asdict, is_dataclass
from typing import Any
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.span import LiveSpan
from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKe... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/pydantic_ai/autolog.py",
"license": "Apache License 2.0",
"lines": 384,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/pydantic_ai/test_pydanticai_fluent_tracing.py | import importlib.metadata
from contextlib import asynccontextmanager
from unittest.mock import patch
import pytest
from packaging.version import Version
from pydantic_ai import Agent, RunContext
from pydantic_ai.messages import ModelResponse, TextPart, ToolCallPart
from pydantic_ai.models.instrumented import Instrumen... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/pydantic_ai/test_pydanticai_fluent_tracing.py",
"license": "Apache License 2.0",
"lines": 371,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/pydantic_ai/test_pydanticai_mcp_tracing.py | from unittest.mock import patch
import pytest
from pydantic_ai.mcp import MCPServerStdio
import mlflow
from mlflow.entities.trace import SpanType
from tests.tracing.helper import get_traces
@pytest.mark.asyncio
async def test_mcp_server_list_tools_autolog():
tools_list = [
{"name": "tool1", "descriptio... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/pydantic_ai/test_pydanticai_mcp_tracing.py",
"license": "Apache License 2.0",
"lines": 88,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:tests/pydantic_ai/test_pydanticai_tracing.py | import importlib.metadata
from unittest.mock import patch
import pytest
from packaging.version import Version
from pydantic_ai import Agent, RunContext
from pydantic_ai.messages import ModelResponse, TextPart, ToolCallPart
from pydantic_ai.usage import Usage
import mlflow
import mlflow.pydantic_ai # ensure the integ... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/pydantic_ai/test_pydanticai_tracing.py",
"license": "Apache License 2.0",
"lines": 418,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/tracing/processor/mlflow_v3.py | import logging
from opentelemetry.sdk.trace import Span as OTelSpan
from opentelemetry.sdk.trace.export import SpanExporter
from mlflow.entities.trace_info import TraceInfo
from mlflow.entities.trace_location import TraceLocation
from mlflow.entities.trace_state import TraceState
from mlflow.tracing.processor.base_ml... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/tracing/processor/mlflow_v3.py",
"license": "Apache License 2.0",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:tests/tracing/processor/test_mlflow_v3_processor.py | import json
from unittest import mock
import mlflow.tracking.context.default_context
from mlflow.entities.span import LiveSpan
from mlflow.entities.trace_status import TraceStatus
from mlflow.environment_variables import MLFLOW_TRACKING_USERNAME
from mlflow.tracing.constant import (
SpanAttributeKey,
TraceMeta... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/tracing/processor/test_mlflow_v3_processor.py",
"license": "Apache License 2.0",
"lines": 137,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:examples/smolagents/tracing.py | """
This is an example for leveraging MLflow's auto tracing capabilities for Smolagents.
For more information about MLflow Tracing, see: https://mlflow.org/docs/latest/llms/tracing/index.html
"""
from smolagents import CodeAgent, LiteLLMModel
import mlflow
# Turn on auto tracing for Smolagents by calling mlflow.smol... | {
"repo_id": "mlflow/mlflow",
"file_path": "examples/smolagents/tracing.py",
"license": "Apache License 2.0",
"lines": 13,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
mlflow/mlflow:mlflow/smolagents/autolog.py | import inspect
import logging
from typing import Any
import mlflow
from mlflow.entities import SpanType
from mlflow.entities.span import LiveSpan
from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey
from mlflow.utils.autologging_utils.config import AutoLoggingConfig
_logger = logging.getLogger(__name__... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/smolagents/autolog.py",
"license": "Apache License 2.0",
"lines": 116,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/smolagents/test_smolagents_autolog.py | from types import SimpleNamespace
from unittest.mock import patch
import pytest
import smolagents
from packaging.version import Version
import mlflow
from mlflow.entities.span import SpanType
from mlflow.tracing.constant import SpanAttributeKey
from tests.tracing.helper import get_traces
_DUMMY_INPUT = "Explain qua... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/smolagents/test_smolagents_autolog.py",
"license": "Apache License 2.0",
"lines": 230,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
mlflow/mlflow:mlflow/models/evaluation/calibration_curve.py | import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from sklearn.calibration import CalibrationDisplay, calibration_curve
def make_multi_class_calibration_plot(
n_classes, y_true, y_probs, calibration_config, label_list
) -> Figure:
"""Generate one calibration plot for all classes of a multi-... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/models/evaluation/calibration_curve.py",
"license": "Apache License 2.0",
"lines": 91,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:mlflow/tracing/client.py | import json
import logging
import time
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from contextlib import nullcontext
from typing import Sequence
import mlflow
from mlflow.entities.assessment import Assessment
from mlflow.entities.model_registry import PromptVersion
from mlflo... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/tracing/client.py",
"license": "Apache License 2.0",
"lines": 660,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:mlflow/utils/yaml_utils.py | import codecs
import os
import shutil
import tempfile
import yaml
from mlflow.utils.file_utils import ENCODING, exists, get_parent_dir
try:
from yaml import CSafeDumper as YamlSafeDumper
from yaml import CSafeLoader as YamlSafeLoader
except ImportError:
from yaml import SafeDumper as YamlSafeDumper
... | {
"repo_id": "mlflow/mlflow",
"file_path": "mlflow/utils/yaml_utils.py",
"license": "Apache License 2.0",
"lines": 99,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
mlflow/mlflow:tests/utils/test_yaml_utils.py | import codecs
import os
from mlflow.utils.yaml_utils import (
read_yaml,
safe_edit_yaml,
write_yaml,
)
from tests.helper_functions import random_file, random_int
def test_yaml_read_and_write(tmp_path):
temp_dir = str(tmp_path)
yaml_file = random_file("yaml")
long_value = 1
data = {
... | {
"repo_id": "mlflow/mlflow",
"file_path": "tests/utils/test_yaml_utils.py",
"license": "Apache License 2.0",
"lines": 64,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:src/mcp/server/mcpserver/context.py | from __future__ import annotations
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, Generic, Literal
from pydantic import AnyUrl, BaseModel
from mcp.server.context import LifespanContextT, RequestT, ServerRequestContext
from mcp.server.elicitation import (
ElicitationResult,
Elicit... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/mcpserver/context.py",
"license": "MIT License",
"lines": 226,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:tests/server/mcpserver/tools/test_base.py | from mcp.server.mcpserver import Context
from mcp.server.mcpserver.tools.base import Tool
def test_context_detected_in_union_annotation():
def my_tool(x: int, ctx: Context | None) -> str:
raise NotImplementedError
tool = Tool.from_function(my_tool)
assert tool.context_kwarg == "ctx"
| {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/server/mcpserver/tools/test_base.py",
"license": "MIT License",
"lines": 7,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/server/auth/test_routes.py | import pytest
from pydantic import AnyHttpUrl
from mcp.server.auth.routes import validate_issuer_url
def test_validate_issuer_url_https_allowed():
validate_issuer_url(AnyHttpUrl("https://example.com/path"))
def test_validate_issuer_url_http_localhost_allowed():
validate_issuer_url(AnyHttpUrl("http://localh... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/server/auth/test_routes.py",
"license": "MIT License",
"lines": 28,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:src/mcp/client/context.py | """Request context for MCP client handlers."""
from mcp.client.session import ClientSession
from mcp.shared._context import RequestContext
ClientRequestContext = RequestContext[ClientSession]
"""Context for handling incoming requests in a client session.
This context is passed to client-side callbacks (sampling, eli... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/context.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/context.py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Generic
from typing_extensions import TypeVar
from mcp.server.experimental.request_context import Experimental
from mcp.server.session import ServerSession
from mcp.shared._context import RequestContext
from mcp.shared.messa... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/context.py",
"license": "MIT License",
"lines": 17,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:src/mcp/client/_transport.py | """Transport protocol for MCP clients."""
from __future__ import annotations
from contextlib import AbstractAsyncContextManager
from typing import Protocol
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
from mcp.shared.message import SessionMessage
TransportStreams = tuple[Memor... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/_transport.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/mcpserver/exceptions.py | """Custom exceptions for MCPServer."""
class MCPServerError(Exception):
"""Base error for MCPServer."""
class ValidationError(MCPServerError):
"""Error in validating parameters or return values."""
class ResourceError(MCPServerError):
"""Error in resource operations."""
class ToolError(MCPServerErro... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/mcpserver/exceptions.py",
"license": "MIT License",
"lines": 11,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:.github/actions/conformance/client.py | """MCP unified conformance test client.
This client is designed to work with the @modelcontextprotocol/conformance npm package.
It handles all conformance test scenarios via environment variables and CLI arguments.
Contract:
- MCP_CONFORMANCE_SCENARIO env var -> scenario name
- MCP_CONFORMANCE_CONTEXT env var... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": ".github/actions/conformance/client.py",
"license": "MIT License",
"lines": 296,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/types/jsonrpc.py | """This module follows the JSON-RPC 2.0 specification: https://www.jsonrpc.org/specification."""
from __future__ import annotations
from typing import Annotated, Any, Literal
from pydantic import BaseModel, Field, TypeAdapter
RequestId = Annotated[int, Field(strict=True)] | str
"""The ID of a JSON-RPC request."""
... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/types/jsonrpc.py",
"license": "MIT License",
"lines": 54,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:src/mcp/client/_memory.py | """In-memory transport for testing MCP servers without network overhead."""
from __future__ import annotations
from collections.abc import AsyncIterator
from contextlib import AbstractAsyncContextManager, asynccontextmanager
from types import TracebackType
from typing import Any
import anyio
from mcp.client._transp... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/_memory.py",
"license": "MIT License",
"lines": 63,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/client/client.py | """Unified MCP Client that wraps ClientSession with transport management."""
from __future__ import annotations
from contextlib import AsyncExitStack
from dataclasses import KW_ONLY, dataclass, field
from typing import Any
from mcp.client._memory import InMemoryTransport
from mcp.client._transport import Transport
f... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/client.py",
"license": "MIT License",
"lines": 245,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:tests/client/test_client.py | """Tests for the unified Client class."""
from __future__ import annotations
from unittest.mock import patch
import anyio
import pytest
from inline_snapshot import snapshot
from mcp import types
from mcp.client._memory import InMemoryTransport
from mcp.client.client import Client
from mcp.server import Server, Serv... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/client/test_client.py",
"license": "MIT License",
"lines": 246,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/client/transports/test_memory.py | """Tests for InMemoryTransport."""
import pytest
from mcp import Client, types
from mcp.client._memory import InMemoryTransport
from mcp.server import Server, ServerRequestContext
from mcp.server.mcpserver import MCPServer
from mcp.types import ListResourcesResult, Resource
@pytest.fixture
def simple_server() -> Se... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/client/transports/test_memory.py",
"license": "MIT License",
"lines": 72,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/issues/test_973_url_decoding.py | """Test that URL-encoded parameters are decoded in resource templates.
Regression test for https://github.com/modelcontextprotocol/python-sdk/issues/973
"""
from mcp.server.mcpserver.resources import ResourceTemplate
def test_template_matches_decodes_space():
"""Test that %20 is decoded to space."""
def se... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/issues/test_973_url_decoding.py",
"license": "MIT License",
"lines": 55,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/issues/test_1574_resource_uri_validation.py | """Tests for issue #1574: Python SDK incorrectly validates Resource URIs.
The Python SDK previously used Pydantic's AnyUrl for URI fields, which rejected
relative paths like 'users/me' that are valid according to the MCP spec and
accepted by the TypeScript SDK.
The fix changed URI fields to plain strings to match the... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/issues/test_1574_resource_uri_validation.py",
"license": "MIT License",
"lines": 109,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/server/lowlevel/test_helper_types.py | """Test helper_types.py meta field.
These tests verify the changes made to helper_types.py:11 where we added:
meta: dict[str, Any] | None = field(default=None)
ReadResourceContents is the return type for resource read handlers. It's used internally
by the low-level server to package resource content before sendin... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/server/lowlevel/test_helper_types.py",
"license": "MIT License",
"lines": 44,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/server/test_stateless_mode.py | """Tests for stateless HTTP mode limitations.
Stateless HTTP mode does not support server-to-client requests because there
is no persistent connection for bidirectional communication. These tests verify
that appropriate errors are raised when attempting to use unsupported features.
See: https://github.com/modelcontex... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/server/test_stateless_mode.py",
"license": "MIT License",
"lines": 141,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/issues/test_1754_mime_type_parameters.py | """Test for GitHub issue #1754: MIME type validation rejects valid RFC 2045 parameters.
The MIME type validation regex was too restrictive and rejected valid MIME types
with parameters like 'text/html;profile=mcp-app' which are valid per RFC 2045.
"""
import pytest
from mcp import Client
from mcp.server.mcpserver im... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/issues/test_1754_mime_type_parameters.py",
"license": "MIT License",
"lines": 47,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/issues/test_1363_race_condition_streamable_http.py | """Test for issue #1363 - Race condition in StreamableHTTP transport causes ClosedResourceError.
This test reproduces the race condition described in issue #1363 where MCP servers
in HTTP Streamable mode experience ClosedResourceError exceptions when requests
fail validation early (e.g., due to incorrect Accept header... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/issues/test_1363_race_condition_streamable_http.py",
"license": "MIT License",
"lines": 226,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:examples/clients/sse-polling-client/mcp_sse_polling_client/main.py | """SSE Polling Demo Client
Demonstrates the client-side auto-reconnect for SSE polling pattern.
This client connects to the SSE Polling Demo server and calls process_batch,
which triggers periodic server-side stream closes. The client automatically
reconnects using Last-Event-ID and resumes receiving messages.
Run w... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/clients/sse-polling-client/mcp_sse_polling_client/main.py",
"license": "MIT License",
"lines": 84,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:examples/servers/sse-polling-demo/mcp_sse_polling_demo/event_store.py | """In-memory event store for demonstrating resumability functionality.
This is a simple implementation intended for examples and testing,
not for production use where a persistent storage solution would be more appropriate.
"""
import logging
from collections import deque
from dataclasses import dataclass
from uuid i... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/servers/sse-polling-demo/mcp_sse_polling_demo/event_store.py",
"license": "MIT License",
"lines": 76,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:examples/servers/sse-polling-demo/mcp_sse_polling_demo/server.py | """SSE Polling Demo Server
Demonstrates the SSE polling pattern with close_sse_stream() for long-running tasks.
Features demonstrated:
- Priming events (automatic with EventStore)
- Server-initiated stream close via close_sse_stream callback
- Client auto-reconnect with Last-Event-ID
- Progress notifications during l... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/servers/sse-polling-demo/mcp_sse_polling_demo/server.py",
"license": "MIT License",
"lines": 157,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:examples/clients/simple-task-client/mcp_simple_task_client/main.py | """Simple task client demonstrating MCP tasks polling over streamable HTTP."""
import asyncio
import click
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
from mcp.types import CallToolResult, TextContent
async def run(url: str) -> None:
async with streamable_http_cli... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/clients/simple-task-client/mcp_simple_task_client/main.py",
"license": "MIT License",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:examples/clients/simple-task-interactive-client/mcp_simple_task_interactive_client/main.py | """Simple interactive task client demonstrating elicitation and sampling responses.
This example demonstrates the spec-compliant polling pattern:
1. Poll tasks/get watching for status changes
2. On input_required, call tasks/result to receive elicitation/sampling requests
3. Continue until terminal status, then retrie... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/clients/simple-task-interactive-client/mcp_simple_task_interactive_client/main.py",
"license": "MIT License",
"lines": 108,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -... | function_complex |
modelcontextprotocol/python-sdk:examples/servers/simple-task-interactive/mcp_simple_task_interactive/server.py | """Simple interactive task server demonstrating elicitation and sampling.
This example shows the simplified task API where:
- server.experimental.enable_tasks() sets up all infrastructure
- ctx.experimental.run_task() handles task lifecycle automatically
- ServerTaskContext.elicit() and ServerTaskContext.create_messag... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/servers/simple-task-interactive/mcp_simple_task_interactive/server.py",
"license": "MIT License",
"lines": 122,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"templa... | function_simple |
modelcontextprotocol/python-sdk:examples/servers/simple-task/mcp_simple_task/server.py | """Simple task server demonstrating MCP tasks over streamable HTTP."""
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
import anyio
import click
import uvicorn
from mcp import types
from mcp.server import Server, ServerRequestContext
from mcp.server.experimental.task_context impor... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "examples/servers/simple-task/mcp_simple_task/server.py",
"license": "MIT License",
"lines": 66,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:src/mcp/client/experimental/task_handlers.py | """Experimental task handler protocols for server -> client requests.
This module provides Protocol types and default handlers for when servers
send task-related requests to clients (the reverse of normal client -> server flow).
WARNING: These APIs are experimental and may change without notice.
Use cases:
- Server ... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/experimental/task_handlers.py",
"license": "MIT License",
"lines": 224,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/client/experimental/tasks.py | """Experimental client-side task support.
This module provides client methods for interacting with MCP tasks.
WARNING: These APIs are experimental and may change without notice.
Example:
```python
# Call a tool as a task
result = await session.experimental.call_tool_as_task("tool_name", {"arg": "value"})... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/client/experimental/tasks.py",
"license": "MIT License",
"lines": 165,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/experimental/request_context.py | """Experimental request context features.
This module provides the Experimental class which gives access to experimental
features within a request context, such as task-augmented request handling.
WARNING: These APIs are experimental and may change without notice.
"""
from collections.abc import Awaitable, Callable
... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/experimental/request_context.py",
"license": "MIT License",
"lines": 171,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/experimental/session_features.py | """Experimental server session features for server→client task operations.
This module provides the server-side equivalent of ExperimentalClientFeatures,
allowing the server to send task-augmented requests to the client and poll for results.
WARNING: These APIs are experimental and may change without notice.
"""
fro... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/experimental/session_features.py",
"license": "MIT License",
"lines": 168,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/experimental/task_context.py | """ServerTaskContext - Server-integrated task context with elicitation and sampling.
This wraps the pure TaskContext and adds server-specific functionality:
- Elicitation (task.elicit())
- Sampling (task.create_message())
- Status notifications
"""
from typing import Any
import anyio
from mcp.server.experimental.ta... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/experimental/task_context.py",
"license": "MIT License",
"lines": 495,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/server/experimental/task_result_handler.py | """TaskResultHandler - Integrated handler for tasks/result endpoint.
This implements the dequeue-send-wait pattern from the MCP Tasks spec:
1. Dequeue all pending messages for the task
2. Send them to the client via transport with relatedRequestId routing
3. Wait if task is not in terminal state
4. Return final result... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/experimental/task_result_handler.py",
"license": "MIT License",
"lines": 179,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/server/experimental/task_support.py | """TaskSupport - Configuration for experimental task support.
This module provides the TaskSupport class which encapsulates all the
infrastructure needed for task-augmented requests: store, queue, and handler.
"""
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from dataclasses im... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/experimental/task_support.py",
"license": "MIT License",
"lines": 90,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/server/lowlevel/experimental.py | """Experimental handlers for the low-level MCP server.
WARNING: These APIs are experimental and may change without notice.
"""
from __future__ import annotations
import logging
from collections.abc import Awaitable, Callable
from typing import Any, Generic
from typing_extensions import TypeVar
from mcp.server.cont... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/lowlevel/experimental.py",
"license": "MIT License",
"lines": 171,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/server/validation.py | """Shared validation functions for server requests.
This module provides validation logic for sampling and elicitation requests
that is shared across normal and task-augmented code paths.
"""
from mcp.shared.exceptions import MCPError
from mcp.types import INVALID_PARAMS, ClientCapabilities, SamplingMessage, Tool, To... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/server/validation.py",
"license": "MIT License",
"lines": 68,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/capabilities.py | """Tasks capability checking utilities.
This module provides functions for checking and requiring task-related
capabilities. All tasks capability logic is centralized here to keep
the main session code clean.
WARNING: These APIs are experimental and may change without notice.
"""
from mcp.shared.exceptions import MC... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/capabilities.py",
"license": "MIT License",
"lines": 74,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/context.py | """TaskContext - Pure task state management.
This module provides TaskContext, which manages task state without any
server/session dependencies. It can be used standalone for distributed
workers or wrapped by ServerTaskContext for full server integration.
"""
from mcp.shared.experimental.tasks.store import TaskStore
... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/context.py",
"license": "MIT License",
"lines": 75,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/helpers.py | """Helper functions for pure task management.
These helpers work with pure TaskContext and don't require server dependencies.
For server-integrated task helpers, use mcp.server.experimental.
"""
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from datetime import datetime, timezon... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/helpers.py",
"license": "MIT License",
"lines": 130,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/in_memory_task_store.py | """In-memory implementation of TaskStore for demonstration purposes.
This implementation stores all tasks in memory and provides automatic cleanup
based on the TTL duration specified in the task metadata using lazy expiration.
Note: This is not suitable for production use as all data is lost on restart.
For productio... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/in_memory_task_store.py",
"license": "MIT License",
"lines": 166,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/message_queue.py | """TaskMessageQueue - FIFO queue for task-related messages.
This implements the core message queue pattern from the MCP Tasks spec.
When a handler needs to send a request (like elicitation) during a task-augmented
request, the message is enqueued instead of sent directly. Messages are delivered
to the client only thro... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/message_queue.py",
"license": "MIT License",
"lines": 173,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/polling.py | """Shared polling utilities for task operations.
This module provides generic polling logic that works for both client→server
and server→client task polling.
WARNING: These APIs are experimental and may change without notice.
"""
from collections.abc import AsyncIterator, Awaitable, Callable
import anyio
from mcp.... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/polling.py",
"license": "MIT License",
"lines": 31,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/resolver.py | """Resolver - An anyio-compatible future-like object for async result passing.
This provides a simple way to pass a result (or exception) from one coroutine
to another without depending on asyncio.Future.
"""
from typing import Generic, TypeVar, cast
import anyio
T = TypeVar("T")
class Resolver(Generic[T]):
"... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/resolver.py",
"license": "MIT License",
"lines": 43,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
modelcontextprotocol/python-sdk:src/mcp/shared/experimental/tasks/store.py | """TaskStore - Abstract interface for task state storage."""
from abc import ABC, abstractmethod
from mcp.types import Result, Task, TaskMetadata, TaskStatus
class TaskStore(ABC):
"""Abstract interface for task state storage.
This is a pure storage interface - it doesn't manage execution.
Implementatio... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/experimental/tasks/store.py",
"license": "MIT License",
"lines": 107,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:src/mcp/shared/response_router.py | """ResponseRouter - Protocol for pluggable response routing.
This module defines a protocol for routing JSON-RPC responses to alternative
handlers before falling back to the default response stream mechanism.
The primary use case is task-augmented requests: when a TaskSession enqueues
a request (like elicitation), th... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "src/mcp/shared/response_router.py",
"license": "MIT License",
"lines": 46,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
modelcontextprotocol/python-sdk:tests/experimental/tasks/client/test_capabilities.py | """Tests for client task capabilities declaration during initialization."""
import anyio
import pytest
from mcp import ClientCapabilities, types
from mcp.client.experimental.task_handlers import ExperimentalTaskHandlers
from mcp.client.session import ClientSession
from mcp.shared._context import RequestContext
from m... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/client/test_capabilities.py",
"license": "MIT License",
"lines": 266,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/client/test_handlers.py | """Tests for client-side task management handlers (server -> client requests).
These tests verify that clients can handle task-related requests from servers:
- GetTaskRequest - server polling client's task status
- GetTaskPayloadRequest - server getting result from client's task
- ListTasksRequest - server listing cli... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/client/test_handlers.py",
"license": "MIT License",
"lines": 711,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/client/test_poll_task.py | """Tests for poll_task async iterator."""
from collections.abc import Callable, Coroutine
from datetime import datetime, timezone
from typing import Any
from unittest.mock import AsyncMock
import pytest
from mcp.client.experimental.tasks import ExperimentalClientFeatures
from mcp.types import GetTaskResult, TaskStat... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/client/test_poll_task.py",
"license": "MIT License",
"lines": 84,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/client/test_tasks.py | """Tests for the experimental client task methods (session.experimental)."""
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
import anyio
import pytest
from anyio import Event
from anyio.abc import TaskGroup
from mcp import Client
from mcp... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/client/test_tasks.py",
"license": "MIT License",
"lines": 257,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_context.py | """Tests for TaskContext and helper functions."""
import pytest
from mcp.shared.experimental.tasks.context import TaskContext
from mcp.shared.experimental.tasks.helpers import create_task_state, task_execution
from mcp.shared.experimental.tasks.in_memory_task_store import InMemoryTaskStore
from mcp.types import CallT... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_context.py",
"license": "MIT License",
"lines": 129,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_integration.py | """End-to-end integration tests for tasks functionality.
These tests demonstrate the full task lifecycle:
1. Client sends task-augmented request (tools/call with task metadata)
2. Server creates task and returns CreateTaskResult immediately
3. Background work executes (using task_execution context manager)
4. Client p... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_integration.py",
"license": "MIT License",
"lines": 203,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_run_task_flow.py | """Tests for the simplified task API: enable_tasks() + run_task()
This tests the recommended user flow:
1. server.experimental.enable_tasks() - one-line setup
2. ctx.experimental.run_task(work) - spawns work, returns CreateTaskResult
3. work function uses ServerTaskContext for elicit/create_message
These are integrat... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_run_task_flow.py",
"license": "MIT License",
"lines": 273,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_server.py | """Tests for server-side task support (handlers, capabilities, integration)."""
from datetime import datetime, timezone
from typing import Any
import anyio
import pytest
from mcp import Client
from mcp.client.session import ClientSession
from mcp.server import Server, ServerRequestContext
from mcp.server.lowlevel im... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_server.py",
"license": "MIT License",
"lines": 656,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_server_task_context.py | """Tests for ServerTaskContext."""
import asyncio
from unittest.mock import AsyncMock, Mock
import anyio
import pytest
from mcp.server.experimental.task_context import ServerTaskContext
from mcp.server.experimental.task_result_handler import TaskResultHandler
from mcp.shared.exceptions import MCPError
from mcp.share... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_server_task_context.py",
"license": "MIT License",
"lines": 569,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_store.py | """Tests for InMemoryTaskStore."""
from collections.abc import AsyncIterator
from datetime import datetime, timedelta, timezone
import pytest
from mcp.shared.exceptions import MCPError
from mcp.shared.experimental.tasks.helpers import cancel_task
from mcp.shared.experimental.tasks.in_memory_task_store import InMemor... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_store.py",
"license": "MIT License",
"lines": 292,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/server/test_task_result_handler.py | """Tests for TaskResultHandler."""
from collections.abc import AsyncIterator
from typing import Any
from unittest.mock import AsyncMock, Mock
import anyio
import pytest
from mcp.server.experimental.task_result_handler import TaskResultHandler
from mcp.shared.exceptions import MCPError
from mcp.shared.experimental.ta... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/server/test_task_result_handler.py",
"license": "MIT License",
"lines": 273,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/test_capabilities.py | """Tests for tasks capability checking utilities."""
import pytest
from mcp import MCPError
from mcp.shared.experimental.tasks.capabilities import (
check_tasks_capability,
has_task_augmented_elicitation,
has_task_augmented_sampling,
require_task_augmented_elicitation,
require_task_augmented_sampl... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/test_capabilities.py",
"license": "MIT License",
"lines": 244,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
modelcontextprotocol/python-sdk:tests/experimental/tasks/test_elicitation_scenarios.py | """Tests for the four elicitation scenarios with tasks.
This tests all combinations of tool call types and elicitation types:
1. Normal tool call + Normal elicitation (session.elicit)
2. Normal tool call + Task-augmented elicitation (session.experimental.elicit_as_task)
3. Task-augmented tool call + Normal elicitation... | {
"repo_id": "modelcontextprotocol/python-sdk",
"file_path": "tests/experimental/tasks/test_elicitation_scenarios.py",
"license": "MIT License",
"lines": 567,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.