OPCFoundation.NetStandard.Opc.Ua.Mcp.Core 2.0.2

Prefix Reserved
dotnet add package OPCFoundation.NetStandard.Opc.Ua.Mcp.Core --version 2.0.2
                    
NuGet\Install-Package OPCFoundation.NetStandard.Opc.Ua.Mcp.Core -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Mcp.Core" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Mcp.Core" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Mcp.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OPCFoundation.NetStandard.Opc.Ua.Mcp.Core --version 2.0.2
                    
#r "nuget: OPCFoundation.NetStandard.Opc.Ua.Mcp.Core, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OPCFoundation.NetStandard.Opc.Ua.Mcp.Core@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OPCFoundation.NetStandard.Opc.Ua.Mcp.Core&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=OPCFoundation.NetStandard.Opc.Ua.Mcp.Core&version=2.0.2
                    
Install as a Cake Tool

OPCFoundation.NetStandard.Opc.Ua.Mcp.Core

OPC UA Model Context Protocol (MCP) tools for the Part 4 services, packaged so they can be embedded in any MCP server host rather than only run as the shipped opcua-mcp tool.

Use this package when an application wants to offer OPC UA tools to an LLM and add tools of its own.

Tools

Connect and session management, browse and view services, read and write attributes, method calls, subscriptions and monitored items, node management, NodeSet2 export, and PKI/certificate administration.

Usage

builder.Services.AddOpcUaMcpCore();

builder.Services.AddMcpServer()
    .WithStdioServerTransport()
    .WithOpcUaMcpFilters()
    .WithOpcUaCoreTools(McpToolProfile.Services)
    .WithTools<MyApplicationTools>();

WithOpcUaMcpFilters registers the request and schema filters that make tool errors actionable and tool schemas explicit; call it once per server even when several OPC UA tool packages are composed.

Profile composition

Each package has a service registration and a catalogue registration. Pass the same McpToolProfileSet to every selected package; unselected profiles contribute no tools. Core deduplicates connection tools across a composed host:

McpToolProfileSet profiles = McpToolProfileSet.Parse("machinery,isa95");
builder.Services.AddOpcUaMcpCore();
builder.Services.AddOpcUaMcpMachinery();
builder.Services.AddOpcUaMcpIsa95();
builder.Services.AddMcpServer()
    .WithStdioServerTransport()
    .WithOpcUaMcpFilters()
    .WithOpcUaCoreTools(profiles)
    .WithOpcUaMachineryTools(profiles)
    .WithOpcUaIsa95Tools(profiles);

Model/package dependencies do not silently register their tool catalogues. Accessors may also be constructed with an existing OpcUaSessionManager; they do not own its sessions. Profile selection, including Full, grants no authority.

Arguments and JSON results

Connect, ConnectCertificate, and ConnectJwt return a session name. Pass sessionName on later calls; omission is valid only when one session is connected. Disconnect closes only the selected session. For example, ReadValue accepts:

{ "nodeId": "ns=2;s=Temperature", "sessionName": "plant" }

Use ConnectCertificate for certificate authentication with a non-secret certificateIdentity name configured by the host and the server's endpointUrl. It fixes the authentication type to Certificate and accepts optional securityMode, securityPolicy, and name. It always validates server trust and has no auto-accept switch. Connect retains its original eight arguments for Anonymous and Username authentication; authType: "Certificate" on that tool fails without an identity selector. Both public C# ConnectAsync overloads, including the certificate-identity overload, remain available. The executable reads McpServer:CertificateIdentities:<name> with StoreType, StorePath, and exactly one of SubjectName or Thumbprint. Embedders populate OpcUaMcpOptions.CertificateIdentities with McpCertificateIdentity entries and can inject ICertificatePasswordProvider for protected keys. The existing certificate store/provider and user-token policy selection perform authentication; tool callers cannot supply private keys or arbitrary certificate-store locations. Unknown references fail closed. Expose these identities only to trusted MCP clients.

Use ConnectJwt with required endpointUrl and jwt arguments for a raw, pre-acquired JWT. Optional arguments are securityMode, securityPolicy, and name; there is no autoAcceptCerts switch. The server must offer IssuedToken with Profiles.JwtUserToken and a usable encrypted channel or user-token policy. Server certificate validation is isolated from shared automatic-accept settings. GetEndpoints includes issuedTokenType and issuerEndpointUrl for each user-token policy.

{
  "endpointUrl": "opc.tcp://server.example:4840",
  "jwt": "<pre-acquired-jwt>",
  "securityMode": "SignAndEncrypt",
  "name": "plant"
}

The tool does not acquire or refresh tokens. The OPC UA server validates the signature and claims. Supply a new token through another ConnectJwt call when needed. Treat tool-call history as secret-bearing storage. See JWT authentication for encryption rules, failure behavior, and the direct OpcUaSessionManager.ConnectJwtAsync API.

NodeIds use OPC UA string notation:

Kind Example
Numeric i=2258
Namespace index and number ns=2;i=1001
String ns=2;s=MyVariable
GUID ns=2;g=12345678-1234-1234-1234-123456789abc
ByteString ns=2;b=AQID

Useful namespace-zero IDs include Root i=84, Objects i=85, Types i=86, Views i=87, Server i=2253 and ServerStatus.CurrentTime i=2258. WriteValue takes explicit dataType plus the encoded value; CallMethod uses objectId, methodId and ordered inputArguments. Use the running catalogue's schema for each service's typed request shape.

Call and CallMethod additionally accept inputArgumentsJson instead of the legacy string array. It is an OPC UA JSON Variant array, for example [{"UaType":8,"Value":"0"},{"UaType":6,"Value":1}] for Int64/Int32 arguments. Structure values use UaType: 22 and a Value object containing UaTypeId and the structure's fields. Load custom types with schema_load_types first. Conflicting argument forms and invalid JSON are rejected before dispatch. Typed input is limited to 4 MiB of UTF-8 JSON and 1,024 arguments. A non-null Value requires an explicit UaType; a missing or misspelled type tag is not silently interpreted as a null argument. Null encodings and typed defaults remain supported. Existing inputArguments strings are never implicitly reinterpreted as JSON.

Generic read/call results retain an ExtensionObject's typeId and decoded body fields through UA codecs. Unregistered encoded bodies remain explicitly encoded; they are not reduced to a type name or silently omitted.

Publish pairs ackSubscriptionIds and ackSequenceNumbers by index. Their lengths must match; omitted and empty arrays both mean no acknowledgements. Its results array preserves each acknowledgement's status in request order, including failures such as BadSequenceNumberUnknown even when the service response itself is Good.

UA JSON preserves types, quality and timestamps. Variant serialization uses BuiltInType, so Boolean false and numeric zero do not become Variant.Null. Non-finite companion measurements are "NaN", "Infinity" or "-Infinity". Companion tools return matching textual JSON and MCP structured content.

Service failures retain their UA status, for example:

{
  "error": true,
  "statusCode": "BadNodeIdUnknown",
  "message": "The node id refers to a node that does not exist in the server address space."
}

Shared companion pages contain items, offset, nextOffset, hasMore and consistency: "live". Page sizes default to 100 and cap at 500; an offset is not a retained snapshot. Observations are finite, report the completion/item/time limit, and dispose only their own enumeration. Individual package contracts may use different limits or continuations.

Connected sessions are exposed through resources/list and resources/read: opcua://sessions, opcua://sessions/{name}, and opcua://sessions/{name}/namespaces.

Host policy and configuration

The executable binds McpServer:Execution; embedding hosts set OpcUaMcpOptions.Execution. Independent capabilities and exact caller/session grants are required. This example grants only local role/user administration:

{
  "McpServer": {
    "ToolProfile": "roles,users",
    "Execution": {
      "EnabledCapabilities": [ "IdentityAdministration" ],
      "CallerGrants": [
        {
          "Caller": {
            "Subject": "stdio",
            "Issuer": "urn:opcfoundation:mcp:local-host",
            "IsLocal": true
          },
          "Capabilities": [ "IdentityAdministration" ],
          "SessionNames": [ "maintenance" ],
          "SecretAliases": []
        }
      ]
    }
  }
}

Stdio uses this explicit local identity. HTTP must authenticate requests and provide a stable subject/issuer; it rejects LocalCallerId as an authority source. Caller-supplied tool arguments never choose the trusted principal. Remote permissions and security mode remain additional requirements.

Host-provisioned sessions require an exact SessionNames ordinary-use grant. Caller-created sessions are private; a use grant never permits replacing or disconnecting another caller's or host-provisioned registration. Custom IMcpOperationPolicy implementations explicitly implement RequireSessionAccess; the additive default implementation denies access.

Protected aliases bind to a strict host-approved registration and its authenticated endpoint/certificate identity. Legacy URI/model aliases are pinned on first approved use; caller-created or autoaccepted targets cannot consume them. Reusing a session name does not transfer its old secret authority. Local trust-store mutation independently requires CertificateAdministration.

Live network rules identify an exact scheme, host, port, operation, resource and permitted CIDRs. Empty grants deny access. DNS is checked at actual connection/reconnection, and sockets use approved IPs while TLS retains the original hostname. UDP/Ethernet add interface/peer/frame rules. See the PubSub and WoT package READMEs for protocol selectors.

An issuance host registers ISecretRegistry, resource-bound McpSecretAlias bindings and an explicit writable ISecretStore through AddOpcUaMcpSecrets before registering domain services. No writable store is chosen implicitly. References reserve capacity before remote issuance; a later persistence failure is a partial outcome, not rollback. Private material never enters a transfer artifact.

Transfer paths

Set OpcUaMcpOptions.TransferRoot and MaxTransferBytes, or executable keys McpServer:TransferRoot / McpServer:MaxTransferBytes. Equivalent environment variables are OPCUA_MCP_TRANSFER_ROOT / OPCUA_MCP_MAX_TRANSFER_BYTES. The directory must exist; the default limit is 64 MiB. No configured root means transfers are disabled.

Paths stay beneath the root. Symlinks, junctions, traversal and Windows alternate data streams are refused. Keep the root and ancestors unwritable by untrusted local users; portable checks do not prevent concurrent privileged replacement. Uploads enforce length before and during reads. Downloads use bounded temporary files and publish without overwrite; failures remove partial output. Parent directories must exist.

See the MCP catalogue for individual tool behavior.

Generic mutations and session lifetime

Generic Call/CallMethod, Write/WriteValue, HistoryUpdate and node/reference mutations capture a SessionRequestContext for stack ManagedSession instances before classification. The same borrowed session performs classification and dispatch. Recovery cannot turn an ordinary preflight into a write to a different session or remapped protected namespace. The host's registered session name, not the server-provided name, remains the policy authority. An acknowledged mutation result is not discarded by a later cancellation or session change.

Embedding compatibility: a custom ISession registered with RegisterExistingSessionAsync must have an explicit host-owned IMcpFixedSessionContract in DI before generic mutations are accepted. Undeclared custom sessions fail closed with BadNotSupported; read-only tools remain unchanged. IsFixed(registration) may return true only when the host guarantees no reconnect, retarget, authentication change, or namespace/type-cache change between classification and dispatch. This grants no operation capability and is not a synthetic SDK generation gate. Stack managed sessions always use the SDK context, regardless of this contract.

The fixed contract and observable metadata are rechecked before dispatch, not after a response. These checks cannot make an independently mutable custom implementation safe; use a stack managed session for that case. Server-side authorization remains authoritative, and remote model changes within the same session are not made into an atomic server transaction.

Captured views preserve immutable authority with SessionInfo.WithSession(capturedSession). Reconstructing a new SessionInfo from its visible name, URI and authentication label does not confer the original registration's authority. Vision file handles similarly retain caller, target, registration and captured-generation provenance rather than exposing raw server handle numbers.

Trimming and Native AOT

The assembly is marked IsAotCompatible on net10.0: its own IL is free of trim and AOT warnings, and tool results are written with Utf8JsonWriter rather than the reflection-based JsonSerializer.

Tool registration in an ahead-of-time published host still requires JSON reflection. The MCP SDK builds each tool's input schema by asking JsonSchemaExporter for a JsonTypeInfo of every parameter type; without a source-generated context covering the tool signatures this throws NotSupportedException. Opc.Ua.Aot.Tests.McpAotTests tests this registration failure.

OPCFoundation.NetStandard.Opc.Ua.Mcp.Diagnostics is deliberately not marked AOT-compatible: it depends on SharpPcap and on reflective service-call dissection.

Package Adds
OPCFoundation.NetStandard.Opc.Ua.Mcp.Diagnostics packet capture, decode and replay, including key logging
OPCFoundation.NetStandard.Opc.Ua.Mcp.PubSub PubSub runtime, actions and discovery
OPCFoundation.NetStandard.Opc.Ua.Mcp.PubSub.Diagnostics PubSub packet capture and decode
OPCFoundation.NetStandard.Opc.Ua.Mcp the ready-to-run opcua-mcp server composing all of the above

License

OPC Foundation MIT License 1.00 — http://opcfoundation.org/License/MIT/1.00/

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (22)

Showing the top 5 NuGet packages that depend on OPCFoundation.NetStandard.Opc.Ua.Mcp.Core:

Package Downloads
OPCFoundation.NetStandard.Opc.Ua.Mcp.Diagnostics

OPC UA MCP tools for protocol diagnostics: UA-TCP packet capture, decode and replay. Embed in any MCP server host.

OPCFoundation.NetStandard.Opc.Ua.Mcp.PubSub.Diagnostics

OPC UA MCP tools for PubSub protocol diagnostics: PubSub packet capture and decode. Embed in any MCP server host.

OPCFoundation.NetStandard.Opc.Ua.Mcp.PubSub

OPC UA MCP tools for PubSub: runtime publisher and subscriber control, PubSub actions and discovery. Embed in any MCP server host.

OPCFoundation.NetStandard.Opc.Ua.Mcp.Robotics

OPC UA MCP tools for Robot Intent: discover, monitor, command, and submit missions to Robotics controllers. Embed in any MCP server host.

OPCFoundation.NetStandard.Opc.Ua.Mcp.Vision

OPC UA MCP tools for OPC 40100-1/-2 Machine Vision control, management, file transfer, assets and health, and Perception discovery, image capture, inference, feedback and frame graphs. Embed one bounded catalog for all Vision models in any MCP server host.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 969 11/11/2026
2.0.1 1,214 10/12/2026
2.0.0 488 10/7/2026
2.0.0-preview.6 95 9/30/2026
2.0.0-preview.5 95 9/17/2026
2.0.0-preview.4 103 9/2/2026
2.0.0-preview.3 950 8/28/2026
2.0.0-preview.2 114 8/24/2026