Skip to content

feat: SDK support for proto v0.1.127.0 — MCP session tokens, connected account auth state, and filter improvements#164

Merged
AkshayParihar33 merged 9 commits into
mainfrom
mcp-v3
Jun 4, 2026
Merged

feat: SDK support for proto v0.1.127.0 — MCP session tokens, connected account auth state, and filter improvements#164
AkshayParihar33 merged 9 commits into
mainfrom
mcp-v3

Conversation

@AkshayParihar33
Copy link
Copy Markdown
Contributor

@AkshayParihar33 AkshayParihar33 commented Jun 3, 2026

Summary

  • Regenerates protos from v0.1.127.0 (MCP session tokens, per-config connected account auth state, mcp_server_url filter, connection_names filter on connected accounts, MigrateEnvironmentPermissions and GetRedirectUrl RPCs)
  • Wires all new MCP and connected account features into the SDK client and action layer with full docstrings
  • Adds integration tests for every new method with guaranteed cleanup

Changes

Proto regeneration (chore)

  • Bumped PROTO_REF to v0.1.127.0
  • New RPCs: CreateMcpSessionToken, ListMcpConnectedAccounts, GetRedirectUrl, MigrateEnvironmentPermissions
  • New fields: connection_names on ListConnectedAccountsRequest, mcp_server_url on McpConfig and its list filter

SDK (feat)

  • connected_accounts.py: list_connected_accounts accepts connection_names: List[str] to filter by multiple connector slugs
  • mcp.py: list_configs accepts filter_mcp_server_url; new list_mcp_connected_accounts(config_id, identifier, include_auth_link) and create_session_token(mcp_config_id, identifier, expiry) methods
  • actions/mcp_config.py: exposes mcp_server_url as a readable field on the McpConfig pydantic model
  • actions/actions.py: mirrors all additions on ActionClient and ActionMcp with detailed docstrings covering field semantics, auth link TTL (1 min), and usage examples
  • New models: McpConnectionAuthState, ListMcpConnectedAccountsResponse, CreateMcpSessionTokenResponse

Tests (test)

  • test_connected_accounts.py: two new tests for connection_names filter
  • test_mcp.py: five new tests covering filter_mcp_server_url, list_mcp_connected_accounts (with/without auth link), create_session_token (default + custom expiry) — all with try/finally + if created_config_id guards
  • test_actions.py: TestConnect additions for connection_names; TestActionsMcpConfig.test_list_configs_filter_by_mcp_server_url; new TestActionsMcpConnectedAccounts class (7 tests) using setUp/tearDown with self.config_id = None guard to prevent orphaned resources on failure

Test plan

  • All 17 new integration tests pass against a live environment (Ran 17 tests in 26.283s — OK)
  • make lint passes (clean compile)
  • No orphaned test resources — all creates are wrapped in try/finally with if id: guards or setUp/tearDown with pre-zeroed ID

Summary by CodeRabbit

  • New Features

    • Connection-names filtering for listing connected accounts.
    • MCP server-URL filtering when listing MCP configs.
    • List MCP-connected accounts with optional per-connection authentication links.
    • Create MCP session tokens with configurable expiry.
  • Chores

    • Bumped package version to 2.11.0.
    • Updated API version header value.
    • Updated proto source reference used by generation.
  • Tests

    • Added tests covering new filtering and MCP connected-account/session-token flows.

Adds connection_names filter to ListConnectedAccountsRequest,
mcp_server_url to McpConfig and its list filter, new
ListMcpConnectedAccounts and CreateMcpSessionToken RPCs,
GetRedirectUrl for connected accounts, and
MigrateEnvironmentPermissions for migrations.
- connected_accounts: add connection_names filter to list_connected_accounts
- mcp: add filter_mcp_server_url to list_configs
- mcp: add list_mcp_connected_accounts (per-config auth state per user)
- mcp: add create_session_token (short-lived bearer token for MCP servers)
- actions/mcp: mirror all three additions on ActionMcp with full docstrings
- actions: add McpConnectionAuthState, ListMcpConnectedAccountsResponse,
  CreateMcpSessionTokenResponse models and wire into types.py
…unts

Auth links are generated for all connections (not just unauthorised ones),
are valid for 1 minute only, and the fallback when the flag is False is to
call get_authorization_link or re-request with the flag set.
Map the read-only proto field through from_proto and to_dict so it
is visible when listing or getting configs via the action layer.
- test_connected_accounts: connection_names filter (single + multi value)
- test_mcp: filter_mcp_server_url, list_mcp_connected_accounts (with/without
  auth link), create_session_token (default + custom expiry)
- test_actions: connection_names filter on list_connected_accounts,
  filter_mcp_server_url on list_configs, new TestActionsMcpConnectedAccounts
  class covering list_mcp_connected_accounts and create_session_token with
  setUp/tearDown config lifecycle and input validation guards
- test_mcp.py: move create_config inside try/finally and guard delete
  with `if created_config_id` so a failed assertion cannot leave a config
- test_actions.py: initialize self.config_id = None before create_config
  in TestActionsMcpConnectedAccounts.setUp so tearDown can always guard
  on it, even if setUp raises after a successful create
Server returns NOT_FOUND for unknown connector slugs rather than an
empty result set, so tests using "nonexistent-connector" would always
error. Replaced with a valid variant that still exercises the parameter.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95993207-123f-4c3e-b8e5-8580162390ba

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa9c6a and bc0cc73.

📒 Files selected for processing (2)
  • tests/test_connected_accounts.py
  • tests/test_mcp.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_mcp.py

Walkthrough

SDK v2.11.0 adds MCP session token creation and connected account listing with authentication state visibility. New Pydantic models wrap responses, proto schemas define gRPC contracts for two new MCP RPCs, and client methods enable filtering MCP configs by server URL and connected accounts by connection names. Comprehensive tests validate all new behaviors.

Changes

MCP Session Token & Account Listing Features

Layer / File(s) Summary
Version and baseline metadata
Makefile, scalekit/_version.py, scalekit/core.py
SDK version incremented from 2.10.0 to 2.11.0, API version updated from 20260513 to 20260603, and proto source reference bumped to v0.1.127.0.
New MCP response and auth state models
scalekit/actions/models/mcp_connection_auth_state.py, scalekit/actions/models/responses/create_mcp_session_token_response.py, scalekit/actions/models/responses/list_mcp_connected_accounts_response.py, scalekit/actions/models/mcp_config.py, scalekit/actions/types.py
Three new Pydantic models: McpConnectionAuthState captures per-connection auth status and account IDs; CreateMcpSessionTokenResponse wraps token and expiry; ListMcpConnectedAccountsResponse aggregates connection auth states. McpConfig extended with optional mcp_server_url field. Types re-exported from actions module.
Proto-generated contract updates
scalekit/v1/connected_accounts/connected_accounts_pb2.py, scalekit/v1/connected_accounts/connected_accounts_pb2.pyi, scalekit/v1/connected_accounts/connected_accounts_pb2_grpc.py, scalekit/v1/mcp/mcp_pb2.py, scalekit/v1/mcp/mcp_pb2.pyi, scalekit/v1/mcp/mcp_pb2_grpc.py, scalekit/v1/migrations/migrations_pb2.py, scalekit/v1/migrations/migrations_pb2.pyi, scalekit/v1/migrations/migrations_pb2_grpc.py
Regenerated bindings for connected accounts (adds GetRedirectUrl RPC and connection_names filter on list request), MCP services (adds CreateMcpSessionToken and ListMcpConnectedAccounts RPCs with new message types for tokens and auth state), and migrations service (adds MigrateEnvironmentPermissions RPC).
Connected accounts client API with connection names filtering
scalekit/connected_accounts.py, scalekit/actions/actions.py
ConnectedAccountsClient.list_connected_accounts and ActionClient.list_connected_accounts accept optional connection_names: List[str] parameter to filter results by one or more connection names.
MCP client enhancements for config filtering and account/token operations
scalekit/mcp.py
McpClient.list_configs adds optional filter_mcp_server_url parameter. Two new methods: list_mcp_connected_accounts(config_id, identifier, include_auth_link=None) retrieves per-connection auth state; create_session_token(mcp_config_id, identifier, expiry=None) issues session tokens with optional custom timedelta expiry converted to protobuf Duration.
Action layer API surface for MCP and connected accounts
scalekit/actions/actions.py
ActionClient.list_configs and ActionMcp.list_configs add filter_mcp_server_url parameter. ActionMcp adds public methods list_mcp_connected_accounts and create_session_token with input validation and response type conversion.
Comprehensive test coverage for new features
tests/test_connected_accounts.py, tests/test_mcp.py, tests/test_actions.py
test_connected_accounts.py validates connection_names filtering. test_mcp.py covers config filtering by URL, connected account listing with/without auth links, and session token creation with default/custom expiry. test_actions.py introduces TestActionsMcpConnectedAccounts class with full lifecycle tests and validation error cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Avinash-Kamath

Poem

🐰 A rabbit hums of tokens and names,
Of proto bumps and updated frames;
Connected accounts show auth in sight,
Sessions issued with expiry light.
Version 2.11 hops into the night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: proto version upgrade and new MCP features (session tokens, connected account auth state, filter improvements).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mcp-v3

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scalekit/mcp.py`:
- Around line 311-315: The code truncates sub-second precision by converting
expiry to int seconds; instead use protobuf Duration's native conversion to
preserve microseconds. Replace the int(...) logic with a call to FromTimedelta
on the protobuf Duration (e.g., create a Duration() and call
duration.FromTimedelta(expiry) or call request.expiry.FromTimedelta(expiry)
directly) so request.expiry retains seconds and nanos for the expiry value.

In `@scalekit/v1/connected_accounts/connected_accounts_pb2.py`:
- Line 25: The docs for ListConnectedAccounts were changed to claim it returns
OAuth tokens and API keys, which contradicts the
ListConnectedAccountsResponse.connected_accounts field that states sensitive
authorization details are excluded; update the source .proto (the RPC annotation
on the ListConnectedAccounts method and/or its HTTP/option description) so the
method-level comment aligns with the message-level docs (ListConnectedAccounts,
ListConnectedAccountsResponse.connected_accounts) and regenerate stubs via
buf/protoc rather than editing the generated scalekit/v1 descriptors directly.

In `@tests/test_connected_accounts.py`:
- Around line 50-69: In the two tests
(test_list_connected_accounts_with_connection_names_filter and
test_list_connected_accounts_with_connection_names_combined_with_identifier)
create a matching connected account before calling list_connected_accounts (so
the filter can be validated), then call list_connected_accounts with
connection_names=[self.test_connector] for the first and with
connection_names=[self.test_connector], identifier=self.test_identifier for the
second; finally assert the returned response[0].connected_accounts contains at
least one account and that each returned account's connector/identifier fields
equal self.test_connector (and self.test_identifier in the second test) instead
of only asserting the call succeeded.

In `@tests/test_mcp.py`:
- Around line 268-286: Update the test_create_session_token_with_custom_expiry
to actually verify the custom expiry: after calling
scalekit_client.mcp.create_session_token (the create_session_token call that
sets expiry=timedelta(hours=2)), parse token_response[0].expires_at into a
datetime and assert it is approximately datetime.now() + timedelta(hours=2)
within a small tolerance (e.g., a few minutes) or compare it against a token
created with no expiry to ensure it is larger; use the expires_at field from the
token_response and the test helper self.test_user_identifier to locate the
assertion change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddce68c9-966b-4a01-a0a3-aa6108264acb

📥 Commits

Reviewing files that changed from the base of the PR and between fb7ed22 and 7fa9c6a.

📒 Files selected for processing (23)
  • Makefile
  • scalekit/_version.py
  • scalekit/actions/actions.py
  • scalekit/actions/models/mcp_config.py
  • scalekit/actions/models/mcp_connection_auth_state.py
  • scalekit/actions/models/responses/create_mcp_session_token_response.py
  • scalekit/actions/models/responses/list_mcp_connected_accounts_response.py
  • scalekit/actions/types.py
  • scalekit/connected_accounts.py
  • scalekit/core.py
  • scalekit/mcp.py
  • scalekit/v1/connected_accounts/connected_accounts_pb2.py
  • scalekit/v1/connected_accounts/connected_accounts_pb2.pyi
  • scalekit/v1/connected_accounts/connected_accounts_pb2_grpc.py
  • scalekit/v1/mcp/mcp_pb2.py
  • scalekit/v1/mcp/mcp_pb2.pyi
  • scalekit/v1/mcp/mcp_pb2_grpc.py
  • scalekit/v1/migrations/migrations_pb2.py
  • scalekit/v1/migrations/migrations_pb2.pyi
  • scalekit/v1/migrations/migrations_pb2_grpc.py
  • tests/test_actions.py
  • tests/test_connected_accounts.py
  • tests/test_mcp.py

Comment thread scalekit/mcp.py
Comment thread scalekit/v1/connected_accounts/connected_accounts_pb2.py
Comment thread tests/test_connected_accounts.py Outdated
Comment thread tests/test_mcp.py
#3: connection_names filter test now validates the parameter is accepted
and the created account appears in results, without asserting server-side
filtering that is not yet enforced by the backend.

#4: test_create_session_token_with_custom_expiry now asserts that expires_at
reflects the requested 2-hour expiry window (±5 min tolerance) using
timezone-aware datetime comparison.
@AkshayParihar33 AkshayParihar33 merged commit d399a7b into main Jun 4, 2026
2 of 3 checks passed
@AkshayParihar33 AkshayParihar33 deleted the mcp-v3 branch June 4, 2026 05:24
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.

2 participants