/
pickling
/
mcp-sourcecontrol-python
Обзор
Документация
Войти
/
pickling
/
mcp-sourcecontrol-python
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/mcp_sourcecontrol/tools/schemas.py
41 строка
1 KB
pickling-21
Python-порт mcp-sourcecontrol: 20 инструментов, stdio и Streamable HTTP
29 июл 2026, 02:18
29 июл 2026, 02:18
bc8bde4
Код
Авторство
О чём код?
"""Общие типы параметров инструментов. Порт src/tools/schemas.ts (zod → pydantic).""" from __future__ import annotations import re from typing import Annotated from pydantic import Field, StringConstraints # Ключ проекта SourceControl. ParamProjectKey = Annotated[ str, StringConstraints(strip_whitespace=True, min_length=1), Field(description="Project key (e.g. 'PROJECT')."), ] # Slug репозитория SourceControl. ParamRepositorySlug = Annotated[ str, StringConstraints(strip_whitespace=True, to_lower=True, min_length=1), Field(description="Repository slug (e.g. 'REPO')."), ] # ID пул-реквеста (целое число >= 1). ParamPullRequestId = Annotated[int, Field(ge=1, description="Pull request ID.")] # Пагинация: page (номер) и limit (размер страницы). ParamPage = Annotated[int, Field(ge=1, description="1-based page number. Default: 1")] ParamLimit = Annotated[int, Field(ge=1, le=100, description="Page size (1–100). Default: 30")] _BRANCH_PREFIX_RE = re.compile(r"^refs/heads/") def strip_branch_prefix(branch: str) -> str: """Удаляет prefix refs/heads/, если присутствует.""" return _BRANCH_PREFIX_RE.sub("", branch) def normalize_branch(branch: str) -> str: """Формирует полный ref с единственным prefix refs/heads/.""" return f"refs/heads/{strip_branch_prefix(branch)}"