Skip to main content
Glama

aga_create_artifact

Create sealed policy artifacts by attesting subjects and loading them into the portal for AI agent enforcement. Accepts content or pre-computed hashes.

Instructions

Attest subject, generate sealed Policy Artifact, load into portal. Accepts content or pre-computed hashes. (Claims 1a-1d)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subject_contentNoContent/bytes of the subject
subject_bytes_hashNoPre-computed SHA-256 bytes hash
subject_metadata_hashNoPre-computed SHA-256 metadata hash
subject_metadataNo
measurement_cadence_msNo
enforcement_actionNo
ttl_secondsNo
measurement_typesNo
evidence_itemsNo
behavioral_baselineNo

Implementation Reference

  • The handleCreateArtifact function implements the core logic for the 'aga_create_artifact' tool, including subject identifier generation, attestation, artifact generation, and portal state updates.
    export async function handleCreateArtifact(args: CreateArtifactArgs, ctx: ServerContext) {
      // Determine subject identifier - support both content and hash inputs
      let subId: { bytes_hash: string; metadata_hash: string };
      if (args.subject_bytes_hash && args.subject_metadata_hash) {
        subId = { bytes_hash: args.subject_bytes_hash, metadata_hash: args.subject_metadata_hash };
      } else if (args.subject_content) {
        subId = computeSubjectIdFromString(args.subject_content, args.subject_metadata ?? {});
      } else {
        return ctx.error('Provide either subject_content or subject_bytes_hash + subject_metadata_hash');
      }
    
      // Build enforcement parameters - merge custom with defaults
      const enforcement = {
        measurement_cadence_ms: args.measurement_cadence_ms ?? ctx.defaultEnforcement.measurement_cadence_ms,
        ttl_seconds: args.ttl_seconds ?? ctx.defaultEnforcement.ttl_seconds,
        enforcement_triggers: args.enforcement_action
          ? [args.enforcement_action as EnforcementAction]
          : ctx.defaultEnforcement.enforcement_triggers,
        re_attestation_required: ctx.defaultEnforcement.re_attestation_required,
        measurement_types: (args.measurement_types ?? ctx.defaultEnforcement.measurement_types.map(String)) as MeasurementType[],
      };
    
      const policyRef = sha256Str(JSON.stringify(enforcement));
      const att = performAttestation({
        subject_identifier: subId,
        policy_reference: policyRef,
        evidence_items: args.evidence_items ?? [],
      });
      if (!att.success || !att.sealed_hash || !att.seal_salt) {
        return ctx.error(att.rejection_reason ?? 'Attestation failed');
      }
    
      // Track whether this is a re-attestation (after revocation)
      const previousArtifact = ctx.activeArtifact;
      const isReAttestation = previousArtifact !== null && (
        ctx.portal.state === 'TERMINATED' || ctx.portal.state === 'SAFE_STATE' ||
        ctx.portal.isRevoked(previousArtifact.sealed_hash)
      );
    
      const artifact = generateArtifact({
        subject_identifier: subId,
        policy_reference: policyRef,
        policy_version: isReAttestation ? (previousArtifact!.policy_version + 1) : 1,
        sealed_hash: att.sealed_hash,
        seal_salt: att.seal_salt,
        enforcement_parameters: enforcement,
        disclosure_policy: ctx.defaultClaims,
        evidence_commitments: att.evidence_commitments,
        issuer_keypair: ctx.issuerKP,
      });
      await ctx.storage.storeArtifact(artifact);
    
      ctx.portal.reset();
      ctx.portal.loadArtifact(artifact, pkToHex(ctx.issuerKP.publicKey));
      ctx.activeArtifact = artifact;
      ctx.quarantine = null;
      ctx.measurementCount = 0;
      ctx.behavioralMonitor.reset();
      if (args.behavioral_baseline) ctx.behavioralMonitor.setBaseline(args.behavioral_baseline);
    
      const eventType = isReAttestation ? 'RE_ATTESTATION' : 'POLICY_ISSUANCE';
      const eventPayload: Record<string, unknown> = {
        artifact_hash: hashArtifact(artifact),
        sealed_hash: artifact.sealed_hash,
      };
      if (isReAttestation && previousArtifact) {
        eventPayload.predecessor_sealed_hash = previousArtifact.sealed_hash;
        eventPayload.predecessor_artifact_hash = hashArtifact(previousArtifact);
      }
      await ctx.appendToChain(eventType as any, eventPayload);
    
      return ctx.json({
        success: true,
        artifact_hash: hashArtifact(artifact),
        sealed_hash: artifact.sealed_hash,
        subject_identifier: subId,
        portal_state: ctx.portal.state,
        issuer_public_key: pkToHex(ctx.issuerKP.publicKey),
        verification_tier: ctx.verificationTier,
        event_type: eventType,
        enforcement_parameters: enforcement,
        evidence_commitments: att.evidence_commitments,
        is_re_attestation: isReAttestation,
      });
    }
  • CreateArtifactArgs defines the input parameters for the 'aga_create_artifact' tool, supporting both content-based and hash-based subject inputs, along with optional enforcement and metadata parameters.
    export interface CreateArtifactArgs {
      // Content-based (V1 pattern)
      subject_content?: string;
      subject_metadata?: SubjectMetadata;
      // Hash-based (V2 pattern - pre-computed hashes)
      subject_bytes_hash?: string;
      subject_metadata_hash?: string;
      // Custom enforcement parameters
      measurement_cadence_ms?: number;
      enforcement_action?: string;
      ttl_seconds?: number;
      measurement_types?: string[];
      // Evidence and behavioral
      evidence_items?: Array<{ label: string; content: string }>;
      behavioral_baseline?: BehavioralBaseline;
    }
  • src/server.ts:95-120 (registration)
    Registration of the 'aga_create_artifact' tool in the MCP server, defining the schema and binding it to the handleCreateArtifact handler.
    server.tool('aga_create_artifact',
      'Attest subject, generate sealed Policy Artifact, load into portal. Accepts content or pre-computed hashes. (Claims 1a-1d)',
      {
        subject_content: z.string().optional().describe('Content/bytes of the subject'),
        subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash'),
        subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash'),
        subject_metadata: z.object({
          filename: z.string().optional(),
          version: z.string().optional(),
          author: z.string().optional(),
          content_type: z.string().optional(),
        }).optional(),
        measurement_cadence_ms: z.number().optional(),
        enforcement_action: z.string().optional(),
        ttl_seconds: z.number().optional(),
        measurement_types: z.array(z.string()).optional(),
        evidence_items: z.array(z.object({ label: z.string(), content: z.string() })).default([]),
        behavioral_baseline: z.object({
          permitted_tools: z.array(z.string()),
          rate_limits: z.record(z.number()),
          forbidden_sequences: z.array(z.array(z.string())),
          window_ms: z.number(),
        }).optional(),
      },
      async (args) => handleCreateArtifact(args, ctx),
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'Attest subject' and 'generate sealed Policy Artifact' which implies a write/mutation operation, but doesn't disclose critical behavioral traits like: whether this requires specific permissions, if it's idempotent, what happens on failure, rate limits, or what 'load into portal' entails. The '(Claims 1a-1d)' reference is cryptic and unhelpful.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (two sentences) but poorly structured. The first sentence is dense with multiple actions ('Attest', 'generate', 'load'), and the parenthetical '(Claims 1a-1d)' adds confusion rather than clarity. While it's brief, the information density is low relative to the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 10 parameters, nested objects, no annotations, and no output schema, the description is severely inadequate. It doesn't explain what a 'Policy Artifact' is, what 'attest subject' means, what the portal is, what happens after loading, or what the cryptic '(Claims 1a-1d)' refers to. The description fails to provide the necessary context for understanding this tool's role in the broader system.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With only 30% schema description coverage and 10 parameters, the description fails to compensate for the significant documentation gap. It mentions 'Accepts content or pre-computed hashes' which only maps to the first 2-3 parameters, leaving 7-8 other parameters (like 'measurement_cadence_ms', 'enforcement_action', 'behavioral_baseline') completely unexplained in both schema and description. The description adds minimal value beyond what little the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Attest subject', 'generate sealed Policy Artifact', 'load into portal') and identifies the resource ('Policy Artifact'). It distinguishes from siblings by focusing on artifact creation rather than verification, delegation, or measurement. However, it doesn't explicitly differentiate from all sibling tools like 'aga_init_chain' or 'aga_export_bundle'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal usage guidance. It mentions 'Accepts content or pre-computed hashes' which gives some context about input options, but doesn't specify when to use this tool versus alternatives like 'aga_verify_artifact', 'aga_revoke_artifact', or 'aga_export_bundle'. No explicit when/when-not guidance or prerequisites are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/attestedintelligence/aga-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server