Skip to main content

cf-service-client

Python client library for calling Cogniflow service operations through MCP.

The package exposes a small API for package code and keeps MCP transport details behind a transport abstraction. It does not resolve semantics or import concrete service implementations.

The same package provides the cf presentation adapter:

cf service list
cf service call add_two_numbers --a 2 --b 3 --outputs-json

The CLI uses ServiceClient directly in the same installation and process. Development is the deterministic default; select production explicitly with --runtime production.

Service Boundary Helpers

cf_service_client is the Python-facing helper package for both sides of the universal service boundary.

Consumer side code uses ServiceClient.call_service(...), which builds cf.service.call.v1 envelopes:

from cf_service_client import ServiceClient

client = ServiceClient.for_runtime("development")
result = client.call_service(
    capability="urn:cf:service:Addition",
    inputs={"a": 2, "b": 3},
    parameters={},
)

Runtime selection is resolved by the private cf-runtime-bootstrap executable installed beside the active Python interpreter. The client does not search PATH or fall back to repository or environment configuration. An explicit home can be supplied with ServiceClient.for_runtime("development", home="/absolute/cogniflow/home"). Bootstrap targets must use stdio; HTTP targets are not supported.

call_service normalizes ergonomic dictionaries to the universal cf.service.call.v1 envelope. Service-level results are returned as cf.service.result.v1 content.

Executor side code can use parse_executor_request(...), ok_result(...), and error_result(...) to read cf.service.executor.v1 requests and build cf.service.result.v1 envelopes:

from collections.abc import Mapping

from cf_service_client.executor import parse_executor_request
from cf_service_client.envelopes import error_result, json_output, ok_result


def execute(request: Mapping[str, object]) -> dict[str, object]:
    parsed = parse_executor_request(request)

    if not parsed.operation_iri.endswith("add_two_numbers"):
        return error_result(
            "UNSUPPORTED_OPERATION",
            f"Unsupported operation: {parsed.operation_iri}",
        )

    result = parsed.inputs["a"] + parsed.inputs["b"]
    return ok_result(outputs=[json_output("result", result)])

Validation example:

result = client.call_service(
    capability="urn:cf:service:PackageTemplateConformanceAssessment",
    constraints={
        "https://cogniflow.odea-project.org/cf#hasTemplateName": "cf-python-package-basic",
        "https://cogniflow.odea-project.org/cf#hasTemplateVersion": "1.0.0",
    },
    inputs={"package_path": "stonecastle/cf_concept_service"},
    parameters={"repository_root": "."},
)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cf_service_client-0.1.11-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file cf_service_client-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for cf_service_client-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 84eea24033e0f6a4e779b253ac8aeb50594707141697ad7e30b73a7354be7d9d
MD5 75de683aa7cdbe255306a9ec878129d2
BLAKE2b-256 b943c993fc625c58366b38356bbfcd7448e7867a25f6448ef0bb026ab2ec7cef

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.11 This release

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page