Skip to content

Commit 421ab37

Browse files
authored
fix: proto descriptor collision and PyPI wheel packaging (#11)
* fix: eager proto registration to avoid descriptor pool collision When both capiscio-sdk and capiscio-mcp are co-installed, the second proto import crashes with DescriptorPoolConflict. Fix: - Eager import of mcp_pb2 in __init__.py to win the registration race - Add try/except around AddSerializedFile with FindFileByName fallback * fix: address review — harden proto collision except clause with message check and schema validation
1 parent d3dc020 commit 421ab37

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

capiscio_mcp/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ async def read_database(query: str) -> list[dict]:
6969
ServerErrorCode,
7070
TrustLevel,
7171
)
72+
73+
# Eagerly register MCP proto descriptor before capiscio-sdk can register its
74+
# simpler version. The MCP proto is a superset (has PolicyDecision* etc.), so
75+
# the SDK can safely fall back to it when it detects a duplicate.
76+
import capiscio_mcp._proto.gen.capiscio.v1.mcp_pb2 as _mcp_pb2 # noqa: F401, E402
77+
7278
from capiscio_mcp.errors import (
7379
GuardError,
7480
ServerVerifyError,

capiscio_mcp/_proto/gen/capiscio/v1/mcp_pb2.py

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Issues = "https://github.com/capiscio/capiscio-mcp-python/issues"
6161
[tool.hatch.build.targets.wheel]
6262
packages = ["capiscio_mcp"]
6363

64+
[tool.hatch.build.targets.wheel.force-include]
65+
"capiscio_mcp/_proto/gen/capiscio" = "capiscio_mcp/_proto/gen/capiscio"
66+
67+
[tool.hatch.build.targets.sdist.force-include]
68+
"capiscio_mcp/_proto/gen/capiscio" = "capiscio_mcp/_proto/gen/capiscio"
69+
6470
[tool.pytest.ini_options]
6571
asyncio_mode = "auto"
6672
testpaths = ["tests"]

0 commit comments

Comments
 (0)