Skip to main content

cred-semantic-kernel

Microsoft Semantic Kernel integration for Cred. OAuth2 credential delegation for AI agents.

Install

pip install cred-semantic-kernel

Quick Start

import os
import semantic_kernel as sk
from cred_semantic_kernel import CredPlugin
from cred import AgentIdentity

# The agent's own did:key identity, created once with cred.generate_agent_identity()
# and persisted with identity.export(); load_agent_identity() stands for your own
# secret store lookup returning that dict.
identity = AgentIdentity.from_export(load_agent_identity())

kernel = sk.Kernel()

plugin = CredPlugin(
    agent_token=os.environ["CRED_AGENT_TOKEN"],
    base_url=os.environ["CRED_BASE_URL"],
    user_id="user_123",
    app_client_id="my_app_client_id",
    token_format="handle",
    agent_identity=identity,
)

kernel.add_plugin(plugin, plugin_name="cred")

Plugin Functions

The cred plugin exposes two kernel functions:

delegate

Parameter Type Description
service string Service slug (e.g. google, github)
scopes string Comma-separated OAuth scopes to request

user_id and app_client_id are pre-configured at construction time, not agent-controlled.

By default, delegate returns a legacy access token for backwards compatibility. Set token_format="handle" to return a brokered delegation id instead, then call use to make allowed service API calls without exposing provider access tokens.

agent_identity is required with token_format="handle". The Cred server issues a Delegation Token (a DPoP-bound JWT) to the agent's own key and accepts it only with a DPoP proof signed by that key. The key stays in your process; it is never sent to the model or the server, and it is not a tool argument. The model only sees delegation_id: the token itself is kept in an in-process map (delegation_id to token and expiry), filled by the delegate tool and read by the use tool, so it never appears in tool output. The use tool raises a clear error if no agent_identity is configured or the delegation_id is unknown or expired (call the delegate tool again).

use

Parameter Type Description
delegation_id string Delegation id returned by delegate
url string Full HTTPS API URL
method string HTTP method
body string Optional JSON body, or empty string
extra_headers string Optional JSON object of service-specific headers, or empty string

When the user hasn't connected the service, the delegate function raises ConsentRequiredError. The error's consent_url attribute contains the URL to redirect the user.

from cred import ConsentRequiredError

try:
    result = plugin.delegate(service="google", scopes="calendar.readonly")
except ConsentRequiredError as e:
    print(f"Redirect user to: {e.consent_url}")

Brokered Server Mode

Point CRED_BASE_URL at your self-hosted @credninja/server deployment and set token_format="handle" when you want the agent to receive delegation ids instead of provider access tokens.

Metadata

Release files for cred-semantic-kernel 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cred-semantic-kernel 2.0.0
File Size Uploaded Provenance Actions
cred_semantic_kernel-2.0.0.tar.gz 12.0 kB Without provenance Details for cred_semantic_kernel-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cred-semantic-kernel 2.0.0
File Interpreter ABI Platform Actions
cred_semantic_kernel-2.0.0-py3-none-any.whl Python 3 none any Details for cred_semantic_kernel-2.0.0-py3-none-any.whl

Total release size: 22.0 kB

Release files / cred_semantic_kernel-2.0.0.tar.gz

Download URL cred_semantic_kernel-2.0.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
574f1b4b7eeddda6dd62d902e5b00ffbb61c5ad2798087c6fa17b962b0cbd0db
BLAKE2b-256 checksum
How to use checksums
0323e1c88cce0250b78741dcc09c6156d9db338a638bc4eba36edf50a62f28ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / cred_semantic_kernel-2.0.0-py3-none-any.whl

Download URL cred_semantic_kernel-2.0.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58743dc4aeee4c054152fd8174458144ae3eacb3db2b839afc9f6833e35b9d56
BLAKE2b-256 checksum
How to use checksums
4ef4724a921e1f8b84d586744a4c47c60bf39054920bcddf0b8a891ae9707d19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for cred-semantic-kernel 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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