@cyanmycelium/mcp-uns
v0.1.0
Published
Unified Namespace identities for mcp-broker domains: UNS ids, their broker resource paths, and per-id access decided by the broker.
Maintainers
Readme
mcp-uns
Unified Namespace identities for the domains above an mcp-broker: SCADA, history, cache. One resource, one UNS id, in every domain, and one broker policy that governs it everywhere.
uns://site1/line1/motor01/speed the durable name: no slot, host, session or protocol address
/site1/line1/motor01/speed the broker resource path the policy evaluatesAn assignment on /site1/line1/** therefore governs the live value (scada.observe), its history (history.read) and its cached value (cache.read) with no second resource model.
What is in it
| export | role |
|---|---|
| UnsPath, UnsId, isPathSegment | parse and compare UNS ids; resourcePath; contains by whole segments (uns://a/b covers uns://a/b/c, not uns://a/bc) |
| IAccessGuard | where a provider asks before serving, one check per id |
| BrokerAccessGuard | the broker decides (broker/authorize on behalf of the caller reference), the provider applies and reports outcomes (broker/audit/result) |
| openGuard() | bench only: allows everything, audits nothing |
| unsChecks(capability, ids) | one check per id, with its resource path |
| callerRefOf(meta), CALLER_META_KEY | the caller reference the broker attaches to each request |
Use
import { DirectTransport } from "@cyanmycelium/mcp-broker-provider";
import { BrokerAccessGuard, unsChecks } from "@cyanmycelium/mcp-uns";
const transport = new DirectTransport(url, { secret });
const guard = new BrokerAccessGuard(transport.broker);
// In a tool handler, with the request context mcp-core 1.4.0 hands an adapter:
const decisions = await guard.authorizeAsync(unsChecks("history.read", ids), request);BrokerAccessGuard never substitutes an identity: a request without a caller reference is denied. An allow-with-constraints carrying constraints is refused and reported refused by default, since a domain with no engineering limits cannot apply them; a domain that applies them (SCADA writes) creates the guard with { constraints: "return" } and receives them on the decision.
The guard depends on no broker package: IBrokerAuthority restates the two methods of mcp-broker-provider's BrokerClient it uses, and DirectTransport.broker satisfies it as is.
Develop
npm install
npm run typecheck
npm test
npm run buildLicense
Apache-2.0.
