File size: 4,181 Bytes
d984ed3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | """
Pydantic data models for the Fabric Config Oracle MCP server.
These models define the canonical shape of:
* A Minecraft version entry parsed from the Mojang version manifest.
* A fully-resolved Fabric mod build configuration.
All MCP tool return values are validated against these models before being
serialized to JSON, ensuring callers always receive well-formed payloads.
"""
from __future__ import annotations
from datetime import datetime
from typing import Literal, Optional
from pydantic import BaseModel, ConfigDict, Field
# ---------------------------------------------------------------------------
# Manifest-level model
# ---------------------------------------------------------------------------
class MinecraftVersion(BaseModel):
"""
A single Minecraft version entry extracted from the Mojang manifest.
Mojang's manifest exposes every released version (stable releases, snapshots,
pre-releases, release candidates) along with an ISO-8601 `releaseTime`. We
use `releaseTime` for sorting because version strings alone are ambiguous
across the dual versioning schemes (legacy `1.21.x` vs year-based `26.x`).
"""
model_config = ConfigDict(frozen=True)
id: str = Field(
...,
description="The version identifier as published by Mojang, e.g. "
"'1.21.4', '26.2', or '26.3 Snapshot 2'.",
)
type: Literal["release", "snapshot"] = Field(
...,
description="Mojang-declared type. Snapshots, pre-releases and "
"release candidates are all bucketed under 'snapshot' for our "
"fallback purposes.",
)
release_time: datetime = Field(
...,
description="ISO-8601 timestamp at which Mojang published the version. "
"Used for newest-first sorting.",
)
url: Optional[str] = Field(
default=None,
description="Optional URL to the per-version manifest JSON. "
"Currently unused but kept for diagnostics.",
)
# ---------------------------------------------------------------------------
# Resolved configuration model
# ---------------------------------------------------------------------------
class FabricConfig(BaseModel):
"""
The fully-resolved Fabric mod build configuration for one Minecraft version.
This is the canonical return type of the `get_optimal_fabric_config` MCP
tool. Every field is populated by the `VersionResolver` after consulting
the Mojang manifest, Fabric Meta, and Modrinth APIs.
"""
minecraft_version: str = Field(
...,
description="The resolved Minecraft version string. May differ from "
"the requested version when the requested version was 'latest' and "
"the resolver had to fall back to a Fabric-supported version.",
)
version_type: Literal["release", "snapshot"] = Field(
...,
description="Whether the resolved minecraft_version is a stable "
"release or a snapshot.",
)
yarn_mappings: str = Field(
default="",
description="Yarn mappings build string (e.g. '26.2+build.1'). "
"Empty string when no Yarn build exists for this MC version.",
)
loader_version: str = Field(
default="",
description="Fabric Loader version (e.g. '0.16.0').",
)
fabric_api_version: str = Field(
default="",
description="Fabric API mod version from Modrinth "
"(e.g. '0.100.0+1.21.4'). Empty when Modrinth has no compatible build.",
)
loom_version: str = Field(
default="1.7-SNAPSHOT",
description="Fabric Loom Gradle plugin version. Not currently fetched "
"from a remote source — a sensible default is provided and may be "
"overridden by the caller.",
)
gradle_wrapper_version: str = Field(
default="8.8",
description="Recommended Gradle wrapper version. Not currently fetched "
"from a remote source — a sensible default is provided.",
)
message: str = Field(
default="",
description="Human-readable status message describing the resolution "
"outcome, including any missing components.",
)
|