npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@protocol-embedded-compliance/mastra

v0.1.0

Published

Protocol-Embedded Compliance (PEC) integration for Mastra AI agents

Readme

@protocol-embedded-compliance/mastra

Protocol-Embedded Compliance (PEC) integration for Mastra AI agents.

What is PEC?

Protocol-Embedded Compliance embeds regulatory requirements into AI agent-tool interactions. MCP servers declare compliance metadata, deployers specify constraints, and agents filter tools automatically.

What is this package?

An MCPClient wrapper that:

  1. Connects to MCP servers
  2. Discovers tools with embedded PEC metadata
  3. Filters against your deployment context
  4. Returns only compliant tools

Installation

pnpm add @protocol-embedded-compliance/mastra @mastra/mcp

Quick Start

import { PecMCPClient, euGeneralContext } from '@protocol-embedded-compliance/mastra'

const client = new PecMCPClient({
  servers: {
    myServer: {
      command: 'npx',
      args: ['my-mcp-server']
    }
  }
})

const { compliant, rejected } = await client.getCompliantTools(euGeneralContext)

console.log(`${compliant.length} tools available, ${rejected.length} filtered out`)

for (const tool of compliant) {
  console.log(`✓ ${tool.name} (${tool.compliance.processing_locations.join(', ')})`)
}

await client.disconnect()

API

PecMCPClient

Wraps Mastra's MCPClient with PEC filtering.

const client = new PecMCPClient({
  servers: {
    // Same config as @mastra/mcp MCPClient
  }
})

// Discover all tools and parse PEC metadata
const { all, withMetadata, withoutMetadata } = await client.discoverTools()

// Get only compliant tools for a deployment context
const { compliant, rejected } = await client.getCompliantTools(context)

// Access raw MCPClient tools (no filtering)
const rawTools = await client.getRawTools()

// Disconnect
await client.disconnect()

filterCompliantTools()

Filter any array of tools with PEC metadata:

import { filterCompliantTools, euGeneralContext } from '@protocol-embedded-compliance/mastra'

const tools = [
  { name: 'tool1', compliance: { /* PEC metadata */ }, tool: actualTool1 },
  { name: 'tool2', compliance: { /* PEC metadata */ }, tool: actualTool2 }
]

const { compliant, rejected } = filterCompliantTools(tools, euGeneralContext)

checkCompliance()

Check a single tool's compliance:

import { checkCompliance, euGeneralContext } from '@protocol-embedded-compliance/mastra'

const result = checkCompliance(toolMetadata, euGeneralContext)
// { compliant: boolean, reasons: string[], warnings: string[] }

Preset Contexts

import {
  euGeneralContext,      // EU, max risk: limited, no US/CN/RU
  euHealthcareContext,   // EU healthcare, special categories allowed
  usHealthcareContext    // US, HIPAA required, no CN/RU/IR/KP
} from '@protocol-embedded-compliance/mastra'

Custom Deployment Context

import type { DeploymentContext } from '@protocol-embedded-compliance/mastra'

const myContext: DeploymentContext = {
  governing_law: 'EU',
  jurisdiction: 'FR',
  data_residency: {
    required: ['EU', 'EEA'],
    prohibited: ['US', 'CN']
  },
  gdpr_requirements: {
    transfer_mechanisms_required: ['ADEQUACY', 'SCCS_2021'],
    special_categories_allowed: false
  },
  risk_classification: {
    maximum_permitted: 'limited'
  },
  sectors: {
    prohibited: ['military']
  },
  certifications: {
    required_any: ['ISO_27001']
  }
}

How MCP Servers Embed PEC Metadata

Servers embed PEC metadata in tool descriptions:

const description = `Summarises documents.

[PEC_COMPLIANCE:{"pec_version":"1.0","processing_locations":["DE","IE"],...}]`

See the PEC Example for a complete implementation.

Filtering Checks

| Check | Description | |-------|-------------| | Location | Tool's processing locations vs required/prohibited | | Risk | AI Act classification vs maximum permitted | | Conformity | Whether tool has undergone conformity assessment | | GDPR Transfer | Required transfer mechanisms for EU | | Special Categories | Art 9 data processing restrictions | | Certifications | Required certifications (HIPAA, ISO 27001, etc.) | | Sectors | Prohibited use cases |

Learn More

Licence

MIT