refactor: align MCP services with assembly-api-client v1.2.6#56
refactor: align MCP services with assembly-api-client v1.2.6#56
Conversation
Prepares AssemblyMCP for the updated assembly-api-client where get_data()
always returns list[BaseModel] (or list[dict] fallback), [] for empty data,
and raises AssemblyAPIError on failure — no more silent dict fallback.
Changes:
- config.py: rename field assembly_api_key → api_key so env_prefix="ASSEMBLY_"
resolves to ASSEMBLY_API_KEY as documented
- services.py _collect_rows: replace nested dict-walker with a simple list
comprehension that handles list[Model] and list[dict] uniformly
- services.py _get_data_with_retry: update return type hint to list[Any]
- services.py DiscoveryService.call_raw: return _collect_rows(raw) so callers
always get JSON-serializable list[dict] instead of raw model instances
- services.py get_committee_members: remove raw dict INFO-200 head parsing;
empty list from _collect_rows now triggers the suggestion logic directly
- tests: update all mock return values from nested dict format
{"SERVICE_ID": [{"head":...}, {"row":[...]}]} to flat list[dict] format
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request renames the assembly API key configuration setting and refactors the data processing logic to handle flat lists of items instead of nested dictionary structures. The _collect_rows function was simplified to process lists of models or dictionaries directly, and the test suite has been extensively updated to align with these structural changes in the API responses. One review comment suggests refining a type hint to include the possibility of string returns in specific scenarios.
| reraise=True, | ||
| ) | ||
| async def _get_data_with_retry(client: AssemblyAPIClient, service_id: str, params: dict[str, Any]) -> dict[str, Any]: | ||
| async def _get_data_with_retry(client: AssemblyAPIClient, service_id: str, params: dict[str, Any]) -> list[Any]: |
There was a problem hiding this comment.
_get_data_with_retry 함수의 반환 타입 힌트가 list[Any]로 되어 있으나, get_data()의 새로운 계약에 따르면 XML 결과인 경우 str을 반환할 수 있습니다. 따라서 타입 힌트를 list[Any] | str로 수정하여 실제 반환 가능한 타입을 정확히 반영하는 것이 좋습니다.
| async def _get_data_with_retry(client: AssemblyAPIClient, service_id: str, params: dict[str, Any]) -> list[Any]: | |
| async def _get_data_with_retry(client: AssemblyAPIClient, service_id: str, params: dict[str, Any]) -> list[Any] | str: |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressed Gemini review: widened return type hint to in commit , then re-ran ................................................................... [100%] |
|
Follow-up: addressed the Gemini review by widening the _get_data_with_retry return type hint to list[Any] | str in commit 0e0dbd0. Re-ran uv run pytest -q and got 67 passed. |
|
Addressed the CI formatting failure by running ruff format on the 5 updated test files, then re-ran uv run ruff format --check . and uv run pytest -q locally. Latest commit: d20b56b. |
Summary
AssemblyMCP를
assembly-api-clientv1.2.6의get_data()반환 계약에 맞춰 정렬합니다.Updated contract
Changes
assemblymcp/config.pyASSEMBLY_API_KEYenvironment loadingassemblymcp/services.pylist[Model] | list[dict]responsestests/docs/PROJECT_STATUS.mdValidation
uv run pytest -qinAssemblyMCP->67 passedassembly-api-clientv1.2.6 and lockfile refreshedRelated
assembly-api-clientmaster@721554a