Django ORM

All models for the MCPClient app.

class smarter.apps.mcpclient.models.MCPAuthType(*values)[source]

Bases: TextChoices

MCP Authentication Type choice list.

API_KEY = 'api_key'
BEARER_TOKEN = 'bearer_token'
NONE = 'none'
OAUTH2 = 'oauth2'
class smarter.apps.mcpclient.models.MCPClient(*args, **kwargs)[source]

Bases: MetaDataWithOwnershipModel

A client of a remote MCP server.

The connection, authentication and capability scope fields are set by the MCPClient manifest’s spec.config. The status fields record the result of the last connection to the MCP server, and are set by smarter.apps.mcpclient.tasks.refresh_mcpclient() and whenever the server’s catalog is fetched.

Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

  • description (Unknown) – Description. A brief description of this resource. Be verbose, but not too verbose.

  • version (Unknown) – Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

  • annotations (Unknown) – Annotations. Key-value pairs for annotating this resource.

  • transport (Unknown) – Transport

  • endpoint_url (Unknown) – Endpoint url. The https URL of the MCP server’s endpoint.

  • command (Unknown) – Command. Reserved for the stdio transport, which is not supported.

  • headers (Unknown) – Headers. Non-secret HTTP headers to send to the MCP server.

  • timeout (Unknown) – Timeout. Seconds to wait for the MCP server to connect and respond.

  • auth_type (Unknown) – Auth type

  • api_key_header (Unknown) – Api key header. The HTTP header that carries an api_key credential.

  • allowed_tools (Unknown) – Allowed tools. Glob patterns of the tool names to offer the LLM; empty = all tools the server advertises.

  • allowed_resources (Unknown) – Allowed resources. Glob patterns of the resource URIs that the LLM may read; empty = none.

  • include_instructions (Unknown) – Include instructions. Add the MCP server’s instructions to the system prompt.

  • cache_ttl (Unknown) – Cache ttl. Seconds to cache the MCP server’s tools, instructions and capabilities. 0 disables caching.

  • is_active (Unknown) – Is active

  • status (Unknown) – Status

  • priority (Unknown) – Priority. The order in which an LLMClient’s MCPClients are offered to the LLM; lower runs first.

  • protocol_version (Unknown) – Protocol version. Negotiated MCP protocol version from the last successful handshake.

  • server_name (Unknown) – Server name. The name that the MCP server reported.

  • server_version (Unknown) – Server version. The version that the MCP server reported.

  • tools (Unknown) – Tools. The names of the tools offered to the LLM, as of the last successful connection.

  • last_connected_at (Unknown) – Last connected at. When Smarter last connected to the MCP server.

  • last_error (Unknown) – Last error. The error of the last failed connection, if any.

Relationship fields:

Parameters:
  • user_profile (Unknown) – User profile (related name: mcpclient)

  • credentials (Unknown) – Credentials. The Secret containing the credential. Required unless auth_type is none. (related name: mcpclient)

  • tags (Unknown) – Tags. Tags for categorizing and organizing this resource. (related name: mcpclient)

  • tagged_items (Unknown) – Tagged items (related name: +)

Reverse relationships:

Parameters:

llmclient_mcpclients (Unknown) – All llmclient mcpclients of this mcp client (related name of mcpclient)

CONNECTION_FIELDS = ('transport', 'endpoint_url', 'headers', 'timeout', 'auth_type', 'credentials_id', 'api_key_header', 'allowed_tools', 'allowed_resources')

The fields that determine what the MCP server returns, and so its cached catalog.

DISCOVERED_FIELDS = ('protocol_version', 'server_name', 'server_version', 'last_connected_at', 'last_error')

The fields that describe the last connection, which a change of connection settings makes stale.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

allowed_resources

JSONField

Allowed resources. Glob patterns of the resource URIs that the LLM may read; empty = none.

Type:

Type

allowed_tools

JSONField

Allowed tools. Glob patterns of the tool names to offer the LLM; empty = all tools the server advertises.

Type:

Type

annotations

JSONField

Annotations. Key-value pairs for annotating this resource.

Type:

Type

api_key_header

CharField

Api key header. The HTTP header that carries an api_key credential.

Type:

Type

auth_type

CharField

Auth type

Choices:

  • none

  • api_key

  • oauth2

  • bearer_token

Type:

Type

cache_ttl

PositiveIntegerField

Cache ttl. Seconds to cache the MCP server’s tools, instructions and capabilities. 0 disables caching.

Type:

Type

command

CharField

Command. Reserved for the stdio transport, which is not supported.

Type:

Type

created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

property credential_name: str | None

The name of the credentials Secret, if any.

credentials

ForeignKey to Secret

Credentials. The Secret containing the credential. Required unless auth_type is none. (related name: mcpclient)

Type:

Type

credentials_id

Internal field, use credentials instead.

description

TextField

Description. A brief description of this resource. Be verbose, but not too verbose.

Type:

Type

endpoint_url

URLField

Endpoint url. The https URL of the MCP server’s endpoint.

Type:

Type

property fingerprint: str

A hash of the fields that determine the MCP server’s catalog.

The cached catalog is keyed by it, so that changing any of these fields invalidates the cache, while recording the status of a connection does not.

Returns:

A 16-character hexadecimal hash.

Return type:

str

get_auth_type_display(*, field=<django.db.models.CharField: auth_type>)

Shows the label of the auth_type. See get_FOO_display() for more information.

get_status_display(*, field=<django.db.models.CharField: status>)

Shows the label of the status. See get_FOO_display() for more information.

get_transport_display(*, field=<django.db.models.CharField: transport>)

Shows the label of the transport. See get_FOO_display() for more information.

headers

JSONField

Headers. Non-secret HTTP headers to send to the MCP server.

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

include_instructions

BooleanField

Include instructions. Add the MCP server’s instructions to the system prompt.

Type:

Type

is_active

BooleanField

Is active

Type:

Type

last_connected_at

DateTimeField

Last connected at. When Smarter last connected to the MCP server.

Type:

Type

last_error

TextField

Last error. The error of the last failed connection, if any.

Type:

Type

llmclient_mcpclients

Reverse ForeignKey from LLMClientMCPClients

All llmclient mcpclients of this mcp client (related name of mcpclient)

Type:

Type

name

CharField

Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

Type:

Type

priority

PositiveSmallIntegerField

Priority. The order in which an LLMClient’s MCPClients are offered to the LLM; lower runs first.

Type:

Type

protocol_version

CharField

Protocol version. Negotiated MCP protocol version from the last successful handshake.

Type:

Type

save(*args, **kwargs)[source]

Save the MCPClient, forgetting what it discovered if its connection settings changed.

Its status, tools and server details describe the last server that it connected to. When, for example, its endpoint_url changes, they no longer describe its server, so they are reset until the refresh that post_save queues connects to the new one. Otherwise the console showed the old server’s tools, and none of them were in a new allowed_tools.

server_name

CharField

Server name. The name that the MCP server reported.

Type:

Type

server_version

CharField

Server version. The version that the MCP server reported.

Type:

Type

status

CharField

Status

Choices:

  • unconfigured

  • connected

  • disconnected

  • error

Type:

Type

tagged_items

Reverse GenericRelation from MCPClient

All + of this tagged item (related name of tagged_items)

Type:

Type

tags = <taggit.managers._TaggableManager object>
timeout

PositiveSmallIntegerField

Timeout. Seconds to wait for the MCP server to connect and respond.

Type:

Type

tools

JSONField

Tools. The names of the tools offered to the LLM, as of the last successful connection.

Type:

Type

transport

CharField

Transport

Choices:

  • stdio

  • sse

  • http

Type:

Type

updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type

user_profile

ForeignKey to UserProfile

User profile (related name: mcpclient)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

version

CharField

Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

Type:

Type

class smarter.apps.mcpclient.models.MCPConnectionStatus(*values)[source]

Bases: TextChoices

MCP Connection Status choice list.

CONNECTED = 'connected'
DISCONNECTED = 'disconnected'
ERROR = 'error'
UNCONFIGURED = 'unconfigured'
class smarter.apps.mcpclient.models.MCPTransport(*values)[source]

Bases: TextChoices

MCP Transport choice list.

stdio is reserved, and not supported.

HTTP = 'http'
SSE = 'sse'
STDIO = 'stdio'