Skip to content

refactor: update references to CapiscioMCPServer.connect() API#10

Merged
beonde merged 6 commits into
mainfrom
refactor/connect-api-rename
May 13, 2026
Merged

refactor: update references to CapiscioMCPServer.connect() API#10
beonde merged 6 commits into
mainfrom
refactor/connect-api-rename

Conversation

@beonde
Copy link
Copy Markdown
Member

@beonde beonde commented May 12, 2026

Summary

Update references from deprecated MCPServerIdentity.from_env() / CapiscIO.from_env() to the new CapiscioMCPServer.connect() / CapiscIO.connect() one-liner APIs.

Files Changed

  • README.md — Update API cross-reference

  • langchain_capiscio/guard.py — Update from_env() docstring

  • Related PRs

  • capiscio-mcp-python: feat/connect-one-liner

  • capiscio-docs: refactor/connect-api-rename"

- README.md: MCPServerIdentity.from_env() → CapiscioMCPServer.connect()
- guard.py: update from_env() docstring to reference connect() pattern
Copilot AI review requested due to automatic review settings May 12, 2026 22:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates documentation cross-references to align with the newer one-liner connect() APIs in the CapiscIO ecosystem (replacing mentions of deprecated from_env() initializers in other packages).

Changes:

  • README: Updates the cross-reference in the “Using Environment Variables” section to point to CapiscIO.connect() / CapiscioMCPServer.connect().
  • CapiscioGuard.from_env() docstring: Updates referenced external APIs from from_env() to connect().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
README.md Updates the external API cross-reference to the newer connect() naming.
langchain_capiscio/guard.py Updates the from_env() docstring to reference connect() APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread langchain_capiscio/guard.py Outdated
Comment thread README.md Outdated
beonde added 2 commits May 12, 2026 20:31
Reword to avoid implying from_env() mirrors connect() — it's an
env-var convenience initializer, not a connect/handshake call.
Copilot AI review requested due to automatic review settings May 13, 2026 13:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

beonde added 2 commits May 13, 2026 09:05
Add connect() classmethod that eagerly connects to the CapiscIO
registry, matching the CapiscIO.connect() and CapiscioMCPServer.connect()
patterns used across the ecosystem.

- connect() reads env vars as fallbacks, validates api_key upfront
- from_env() now delegates to connect() (kept as convenience alias)
- README updated to feature connect() as the primary API
- 6 new unit tests for connect() and from_env() delegation
Copilot AI review requested due to automatic review settings May 13, 2026 14:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

tests/unit/test_guard.py:186

  • This test does not isolate CAPISCIO_DEV_MODE from the process environment. If it’s set externally, CapiscioGuard.connect(..., mode="log") will forward dev_mode=True and break the assert_called_once_with(...) expectation. Consider clearing CAPISCIO_DEV_MODE (and any other relevant CAPISCIO_* vars) within the test.
        mock_sdk = MagicMock()
        mock_sdk.CapiscIO.connect.return_value = fake_identity
        mock_sdk.SecurityConfig.development.return_value = FakeConfig("warn")

        with patch.dict(sys.modules, {"capiscio_sdk": mock_sdk}):
            guard = CapiscioGuard.connect(
                api_key="cap_explicit",
                mode="log",
                name="my-agent",
                server_url="https://dev.registry.capisc.io",
            )

        assert guard._initialized is True
        assert guard.mode == "log"
        mock_sdk.CapiscIO.connect.assert_called_once_with(
            "cap_explicit",
            name="my-agent",
            server_url="https://dev.registry.capisc.io",
        )

tests/unit/test_guard.py:250

  • Like the other connect tests, this assertion assumes no extra env-derived kwargs (e.g. CAPISCIO_AGENT_NAME / CAPISCIO_SERVER_URL) are present. If those env vars are set in the runner, CapiscioGuard.connect() will forward them and the call assertion will fail. Consider explicitly clearing them in the test setup alongside CAPISCIO_API_KEY/CAPISCIO_DEV_MODE.
        old_key = os.environ.get("CAPISCIO_API_KEY")
        old_dev = os.environ.get("CAPISCIO_DEV_MODE")
        os.environ["CAPISCIO_API_KEY"] = "cap_test"
        os.environ["CAPISCIO_DEV_MODE"] = "true"
        try:
            with patch.dict(sys.modules, {"capiscio_sdk": mock_sdk}):
                CapiscioGuard.connect()
        finally:
            if old_key is not None:
                os.environ["CAPISCIO_API_KEY"] = old_key
            else:
                os.environ.pop("CAPISCIO_API_KEY", None)
            if old_dev is not None:
                os.environ["CAPISCIO_DEV_MODE"] = old_dev
            else:
                os.environ.pop("CAPISCIO_DEV_MODE", None)

        mock_sdk.CapiscIO.connect.assert_called_once_with(
            "cap_test",
            dev_mode=True,
        )

Comment thread langchain_capiscio/guard.py Outdated
Comment thread README.md Outdated
Comment thread tests/unit/test_guard.py Outdated
Comment thread langchain_capiscio/guard.py
- Change dev_mode param from bool=False to bool|None=None so explicit
  False overrides CAPISCIO_DEV_MODE env var
- Fix from_env() docstring to mention kwargs override env vars
- Fix README constructor signature to show keyword-only args
- Isolate tests from runner env vars using patch.dict(os.environ)
- Add test for dev_mode=False overriding env var
@beonde beonde merged commit 162c40e into main May 13, 2026
5 checks passed
@beonde beonde deleted the refactor/connect-api-rename branch May 13, 2026 14:59
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