经 AI Skill Hub 精选评估,Pydantic Resolve 获评「强烈推荐」。这款MCP工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 8.0 分,适合有一定技术背景的用户使用。
Python实现的MCP工具,提供清晰的架构设计
Pydantic Resolve 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
Python实现的MCP工具,提供清晰的架构设计
Pydantic Resolve 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/KLR-Pattern/pydantic-resolve
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"pydantic-resolve": {
"command": "npx",
"args": ["-y", "pydantic-resolve"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 Pydantic Resolve 执行以下任务... Claude: [自动调用 Pydantic Resolve MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"pydantic_resolve": {
"command": "npx",
"args": ["-y", "pydantic-resolve"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
Clean Architecture for Python — define business entities, declare relationships, let the framework assemble your data.
Requirements: Python 3.10+, Pydantic v2
---
@router.get("/tasks") async def get_tasks(): tasks = await task_service.get_tasks() user_ids = list({t.owner_id for t in tasks}) users = await user_service.get_users_by_ids(user_ids) user_map = {u.id: u for u in users} return [ TaskResponse({t.model_dump(), 'owner': user_map.get(t.owner_id)}) for t in tasks ]
python
class TaskView(BaseModel): id: int title: str owner_id: int owner: Optional[UserView] = None
def resolve_owner(self, loader=Loader(user_loader)): # Interface Adapter return loader.load(self.owner_id)
@router.get("/tasks") async def get_tasks(): tasks = [TaskView.model_validate(t) for t in await task_repo.get_tasks()] return await Resolver().resolve(tasks) # Application Business Rules ```
Advantages of the new approach:
resolve_* declares "what data is needed", the framework handles "how to batch-fetch it"pip install pydantic-resolve
pip install pydantic-resolve[mcp] # with MCP support
Throughout the Quick Start, we build one API:
Sprint has many TaskTask has one owner (a User)task_count and contributorsExpected response structure:
{
"id": 1,
"name": "Sprint 1",
"tasks": [
{
"id": 101,
"title": "Implement login",
"owner_id": 1,
"owner": {
"id": 1,
"name": "Alice"
}
}
],
"task_count": 1,
"contributor_names": ["Alice"]
}
Each step adds one concept on top of the previous code.
Here is the same Sprint -> Task -> User example after moving relationship wiring into an ER Diagram:
from typing import Annotated, Optional
from pydantic import BaseModel
from pydantic_resolve import Relationship, base_entity, config_global_resolver
BaseEntity = base_entity()
class UserEntity(BaseModel, BaseEntity):
id: int
name: str
class TaskEntity(BaseModel, BaseEntity):
__relationships__ = [
Relationship(fk='owner_id', name='owner', target=UserEntity, loader=user_loader)
]
id: int
title: str
owner_id: int
class SprintEntity(BaseModel, BaseEntity):
__relationships__ = [
Relationship(fk='id', name='tasks', target=list[TaskEntity], loader=task_loader)
]
id: int
name: str
diagram = BaseEntity.get_diagram()
AutoLoad = diagram.create_auto_load()
config_global_resolver(diagram)
class TaskView(TaskEntity):
owner: Annotated[Optional[UserEntity], AutoLoad()] = None
class SprintView(SprintEntity):
tasks: Annotated[list[TaskView], AutoLoad()] = []
task_count: int = 0
def post_task_count(self):
return len(self.tasks)
Compared with the Core API version:
resolve_owner disappears.resolve_tasks disappears.post_* still works exactly the same.If you want to hide internal FK fields such as owner_id, add DefineSubset on top of the ERD setup:
from pydantic_resolve import DefineSubset
class TaskSummary(DefineSubset):
__subset__ = (TaskEntity, ('id', 'title'))
owner: Annotated[Optional[UserEntity], AutoLoad()] = None
Start with resolve_* and post_* on one endpoint. You gain immediate N+1 protection without changing your architecture.
ERD not only drives REST APIs, but also powers GraphQL queries, MCP services, and admin tools.
| Question | Hand-written Core API | ER Diagram + AutoLoad |
|---|---|---|
| First endpoint | Faster | Slower |
| Upfront setup | Low | Medium |
| Reusing the same relation in many models | Repetitive | Centralized |
| Changing a relationship later | Update many resolve_* methods | Update one ERD declaration |
| GraphQL / MCP generation | Separate work | Natural extension |
ERD mode asks for more discipline up front:
AutoLoad from the same diagram used by the resolver.That setup cost is real. The payoff is that relationship knowledge converges into one place — this is precisely the responsibility of Clean Architecture's Enterprise Business Rules layer (Entity Layer): defining core business knowledge independent of external frameworks, so that the database, API, GraphQL, and MCP are all just different projections of it.
| Dimension | ORM-First | Entity-First |
|---|---|---|
| Type source of truth | ORM model | Entity (Pydantic) |
| Relationship wiring | Repeated per endpoint | Centralized in ERD |
| Data assembly | Manual in Service/Route | Automatic via Resolver |
| N+1 prevention | Manual eager loading | Built-in DataLoader batching |
| Multi-data source | Scattered conversion code | Unified Loader interface |
| API contract stability | Tied to DB schema | Independent of DB |
| Feature | GraphQL | pydantic-resolve |
|---|---|---|
| **N+1 Prevention** | Manual DataLoader setup | Built-in automatic batching |
| **Type Safety** | Separate schema files | Native Pydantic types |
| **Learning Curve** | Steep (Schema, Resolvers, Loaders) | Moderate (Loader/batch pattern required) |
| **Debugging** | Complex introspection | Standard Python debugging |
| **Integration** | Requires dedicated server | Works with any framework |
| **Query Flexibility** | Any client can query anything | Explicit API contracts |
Note: pydantic-resolve borrows the DataLoader batch pattern from GraphQL ecosystems. The main difference is that you keep your existing REST framework and get automatic batching without adopting a full GraphQL server. If your project already uses strawberry or ariadne and is happy with it, pydantic-resolve may be redundant.
---
高质量的Python MCP工具,架构清晰
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
AI Skill Hub 点评:Pydantic Resolve 的核心功能完整,质量优秀。对于Claude Desktop / Claude Code 用户来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | pydantic-resolve |
| Topics | bfffastapifullstackgraphqlmcppython |
| GitHub | https://github.com/KLR-Pattern/pydantic-resolve |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-06 · 更新时间:2026-06-06 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端