Skip to main content
Glama

get_project_context

Get a redacted project snapshot: secrets metadata, environment, declared providers, hooks, and audit activity. Use as the first call to orient an AI agent without exposing plaintext secret values.

Instructions

[agent] Return a single redacted snapshot of everything an AI agent typically wants to know about this project: secrets present (keys + metadata only), detected env, manifest declarations, configured providers, registered hooks, and recent audit activity. Use this as the very first call in a session to orient the agent before it asks for any individual secret; prefer list_secrets for a flat key listing, check_project for manifest-vs-keyring drift, and audit_log for a deeper access trail. Read-only and value-safe — no plaintext secret values are ever included. Returns a single pretty-printed JSON document; shape is intentionally broad and may grow over time, so read defensively.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNoWhere the secret lives. 'global' = user keyring (default if omitted on reads), 'project' = scoped to projectPath, 'team' = team-shared (needs teamId), 'org' = org-shared (needs orgId).
projectPathNoAbsolute path to the project root for project-scoped secrets and policy resolution. Defaults to the MCP server's current working directory when omitted.
teamIdNoTeam identifier for team-scoped secrets. Required only when scope='team'. Example: 'acme-platform'.
orgIdNoOrganization identifier for org-scoped secrets. Required only when scope='org'. Example: 'acme-corp'.

Implementation Reference

  • Core handler function that builds the ProjectContext object: collects secrets (redacted), manifest info, environment detection, providers, hooks, and recent audit activity. This is the actual business logic executed when 'get_project_context' is called.
    export function getProjectContext(opts: KeyringOptions = {}): ProjectContext {
      const projectPath = opts.projectPath ?? process.cwd();
      const envResult = collapseEnvironment({ projectPath });
    
      const secretsList = listSecrets({
        ...opts,
        projectPath,
        silent: true,
      });
    
      let expiredCount = 0;
      let staleCount = 0;
      let protectedCount = 0;
    
      const secrets: SecretSummary[] = secretsList.map((entry) => {
        const meta = entry.envelope?.meta;
        const decay = entry.decay;
    
        if (decay?.isExpired) expiredCount++;
        if (decay?.isStale) staleCount++;
        if (meta?.requiresApproval) protectedCount++;
    
        return {
          key: entry.key,
          scope: entry.scope,
          tags: meta?.tags,
          description: meta?.description,
          provider: meta?.provider,
          requiresApproval: meta?.requiresApproval,
          jitProvider: meta?.jitProvider,
          hasStates: !!(entry.envelope?.states && Object.keys(entry.envelope.states).length > 0),
          isExpired: decay?.isExpired ?? false,
          isStale: decay?.isStale ?? false,
          timeRemaining: decay?.timeRemaining ?? null,
          accessCount: meta?.accessCount ?? 0,
          lastAccessed: meta?.lastAccessedAt ?? null,
          rotationFormat: meta?.rotationFormat,
        };
      });
    
      // Manifest analysis
      let manifest: ProjectContext["manifest"] = null;
      const config = readProjectConfig(projectPath);
      if (config?.secrets) {
        const declaredKeys = Object.keys(config.secrets);
        const existingKeys = new Set(secrets.map((s) => s.key));
        const missing = declaredKeys.filter((k) => !existingKeys.has(k));
        manifest = { declared: declaredKeys.length, missing };
      }
    
      // Recent audit activity (last 20 events, redacted)
      const recentEvents = queryAudit({ limit: 20 });
      const recentActions = recentEvents.map((e) => ({
        action: e.action,
        key: e.key,
        source: e.source,
        timestamp: e.timestamp,
      }));
    
      return {
        projectPath,
        environment: envResult
          ? { env: envResult.env, source: envResult.source }
          : null,
        secrets,
        totalSecrets: secrets.length,
        expiredCount,
        staleCount,
        protectedCount,
        manifest,
        validationProviders: providerRegistry.listProviders().map((p) => p.name),
        jitProviders: jitRegistry.listProviders().map((p) => p.name),
        hooksCount: listHooks().length,
        recentActions,
      };
    }
  • Type definitions for SecretSummary and ProjectContext interfaces that define the shape of the return value of get_project_context.
    export interface SecretSummary {
      key: string;
      scope: string;
      tags?: string[];
      description?: string;
      provider?: string;
      requiresApproval?: boolean;
      jitProvider?: string;
      hasStates: boolean;
      isExpired: boolean;
      isStale: boolean;
      timeRemaining: string | null;
      accessCount: number;
      lastAccessed: string | null;
      rotationFormat?: string;
    }
    
    export interface ProjectContext {
      projectPath: string;
      environment: {
        env: string;
        source: string;
      } | null;
      secrets: SecretSummary[];
      totalSecrets: number;
      expiredCount: number;
      staleCount: number;
      protectedCount: number;
      manifest: {
        declared: number;
        missing: string[];
      } | null;
      validationProviders: string[];
      jitProviders: string[];
      hooksCount: number;
      recentActions: Array<{
        action: string;
        key?: string;
        source: string;
        timestamp: string;
      }>;
    }
  • MCP tool handler registration for 'get_project_context'. This is the entry point that receives MCP params, enforces policy, calls getProjectContext(), and returns the result as JSON text.
    server.tool(
      "get_project_context",
      [
        "[agent] Return a single redacted snapshot of everything an AI agent typically wants to know about this project: secrets present (keys + metadata only), detected env, manifest declarations, configured providers, registered hooks, and recent audit activity.",
        "Use this as the very first call in a session to orient the agent before it asks for any individual secret; prefer `list_secrets` for a flat key listing, `check_project` for manifest-vs-keyring drift, and `audit_log` for a deeper access trail.",
        "Read-only and value-safe — no plaintext secret values are ever included. Returns a single pretty-printed JSON document; shape is intentionally broad and may grow over time, so read defensively.",
      ].join(" "),
      {
        scope,
        projectPath,
        teamId,
        orgId,
      },
      async (params) => {
        const toolBlock = enforceToolPolicy(
          "get_project_context",
          params.projectPath,
        );
        if (toolBlock) return toolBlock;
    
        const context = getProjectContext(opts(params));
        return text(JSON.stringify(context, null, 2));
      },
    );
  • Registration of all MCP tools on the server. registerProjectTools (which registers 'get_project_context') is called on line 21.
    export function registerMcpTools(server: McpServer): void {
      registerSecretTools(server);
      registerProjectTools(server);
      registerTunnelTools(server);
      registerTeleportTools(server);
      registerAuditTools(server);
      registerValidationTools(server);
      registerHookTools(server);
      registerToolingTools(server);
      registerAgentTools(server);
      registerPolicyTools(server);
    }
  • Helper function 'opts()' that converts MCP tool params into KeyringOptions, used by the get_project_context handler to pass options to getProjectContext().
    export function opts(params: {
      scope?: string;
      projectPath?: string;
      env?: string;
      teamId?: string;
      orgId?: string;
    }): KeyringOptions {
      return {
        scope: params.scope as Scope | undefined,
        projectPath: params.projectPath ?? process.cwd(),
        teamId: params.teamId,
        orgId: params.orgId,
        env: params.env,
        source: "mcp",
      };
    }
Behavior4/5

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

Discloses read-only nature, no plaintext values, output format, and that shape may grow; lacks details on auth requirements or performance but compensates for no annotations.

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

Conciseness4/5

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

Description is moderately sized and front-loaded with the primary action, though could be slightly more concise without losing key information.

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

Completeness4/5

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

Given 4 optional parameters and no output schema, description covers output shape, safety, and defensive reading; could mention error handling or size limits.

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

Parameters3/5

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

Input schema fully describes parameters; description adds no further parameter meaning beyond what schema provides, meeting baseline.

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

Purpose5/5

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

Description clearly states the tool returns a redacted snapshot of project context, listing specific contents and differentiating from siblings like list_secrets and audit_log.

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

Usage Guidelines5/5

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

Explicitly advises using this as the first call in a session and directs to alternative tools for specific needs (list_secrets, check_project, audit_log).

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/I4cTime/quantum_ring'

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