Skip to content

refactor: align MCP services with assembly-api-client v1.2.6#56

Merged
StatPan merged 5 commits intomasterfrom
refactor/pydantic-model-first
Mar 31, 2026
Merged

refactor: align MCP services with assembly-api-client v1.2.6#56
StatPan merged 5 commits intomasterfrom
refactor/pydantic-model-first

Conversation

@StatPan
Copy link
Copy Markdown
Owner

@StatPan StatPan commented Mar 31, 2026

Summary

AssemblyMCP를 assembly-api-client v1.2.6의 get_data() 반환 계약에 맞춰 정렬합니다.

Updated contract

async def get_data(...) -> list[BaseModel] | list[dict] | str

Changes

  • assemblymcp/config.py
    • align API key field naming with ASSEMBLY_API_KEY environment loading
  • assemblymcp/services.py
    • simplify row collection for list[Model] | list[dict] responses
    • return JSON-serializable rows from discovery raw calls
    • handle empty committee-member results with suggestion flow
  • tests/
    • update mocks from legacy nested raw payloads to the new list-based contract
  • docs/PROJECT_STATUS.md
    • add current status note and validation summary

Validation

  • uv run pytest -q in AssemblyMCP -> 67 passed
  • smoke-checked real API calls for bills, members, meetings, and committees
  • paired client repo already updated to assembly-api-client v1.2.6 and lockfile refreshed

Related

  • paired client repo change: assembly-api-client master @ 721554a

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>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread assemblymcp/services.py Outdated
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]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

_get_data_with_retry 함수의 반환 타입 힌트가 list[Any]로 되어 있으나, get_data()의 새로운 계약에 따르면 XML 결과인 경우 str을 반환할 수 있습니다. 따라서 타입 힌트를 list[Any] | str로 수정하여 실제 반환 가능한 타입을 정확히 반영하는 것이 좋습니다.

Suggested change
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:

StatPan and others added 2 commits April 1, 2026 00:35
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@StatPan StatPan changed the title refactor: align with new get_data() contract (list[Model] | list[dict]) refactor: align MCP services with assembly-api-client v1.2.6 Mar 31, 2026
@StatPan
Copy link
Copy Markdown
Owner Author

StatPan commented Mar 31, 2026

Addressed Gemini review: widened return type hint to in commit , then re-ran ................................................................... [100%]
67 passed in 7.29s ().

@StatPan
Copy link
Copy Markdown
Owner Author

StatPan commented Mar 31, 2026

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.

@StatPan
Copy link
Copy Markdown
Owner Author

StatPan commented Mar 31, 2026

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.

@StatPan StatPan merged commit 72e605a into master Mar 31, 2026
@StatPan StatPan deleted the refactor/pydantic-model-first branch March 31, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant