Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0sec labs 0 loadScope

From Leeroopedia
Knowledge Sources
Domains MCP, Scope_Enforcement, Security_Policy
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for loading a scope policy JSON file and resolving an engagement posture that gates tool availability, provided by the 0security core scope module.

Description

The loadScope function loads a JSON scope file and returns a ScopePolicy (host allowlist, path policy). The isScopeEnforcementEnabled and getScopeEnforcementState functions check whether scope enforcement is active. The resolveEngagementProfile function takes EngagementProfileInputs and returns an EngagementPosture that hardens the server's posture (standard vs conservative). Scope enforcement gates offensive tool availability: offensive tools are blocked when enforcement is enabled without an authorized scope.

Usage

Import these when you need to enforce scope boundaries and engagement posture in the MCP server or agent loop. They are Step 2 of the MCP server integration workflow.

Code Reference

Source Location

  • Repository: 0security
  • File: packages/core/src/scope/scope.ts:L176-178, packages/core/src/scope/activation.ts:L35-37, packages/core/src/scope/engagement-profile.ts:L205+

Signature

export function loadScope(path: string): ScopePolicy;

export function isScopeEnforcementEnabled(): boolean;

export function getScopeEnforcementState(): { enabled: boolean; ... };

export function resolveEngagementProfile(inputs: EngagementProfileInputs): EngagementPosture;

class ScopePolicy {
  static fromJsonFile(path: string): ScopePolicy;
  match(url: string): ScopeMatch;
  // host allowlist, path policy
}

interface EngagementProfileInputs {
  profile?: string;            // "standard" | "conservative"
  scope?: ScopePolicy;
  // ... additional inputs
}

interface EngagementPosture {
  // hardened posture config that gates tool availability and rate limits
}

Import

import { loadScope, isScopeEnforcementEnabled, getScopeEnforcementState, resolveEngagementProfile } from "@0/core";

I/O Contract

Inputs

Name Type Required Description
path string Yes (loadScope) /// JSON scope file path
inputs EngagementProfileInputs Yes (resolveEngagementProfile) /// Profile name + scope

Outputs

Name Type Description
loadScope return ScopePolicy /// Host allowlist + path policy
isScopeEnforcementEnabled return boolean /// Whether scope enforcement is active
resolveEngagementProfile return EngagementPosture /// Hardened posture config

Usage Examples

Scope enforcement in MCP server

import { loadScope, isScopeEnforcementEnabled, resolveEngagementProfile } from "@0/core";

const scope = loadScope("./scope.json");
const posture = resolveEngagementProfile({
  profile: "conservative",
  scope,
});
console.log(`Scope enforcement: ${isScopeEnforcementEnabled()}`);
console.log(`Posture: ${JSON.stringify(posture)}`);

Scope file format

{
  "hosts": ["example.com", "*.target.com"],
  "paths": ["/api/*"],
  "deny": ["admin.example.com"]
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment