Skip to main content
Glama

import_postman_environment

Import a Postman environment JSON file to create a local environment, supporting initial and current variable values for API testing.

Instructions

Importa un Postman Environment (JSON) como entorno local. Soporta variables con valores initial/current.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesRuta al archivo .postman_environment.json exportado de Postman
nameNoNombre para el entorno (default: usa el nombre del archivo Postman)
overwriteNoSobreescribir si ya existe un entorno con el mismo nombre (default: false)
activateNoActivar el entorno importado como entorno activo (default: false)

Implementation Reference

  • src/server.ts:68-68 (registration)
    Registration of registerUtilityTools which includes import_postman_environment tool.
    registerUtilityTools(server, storage)
  • src/server.ts:10-10 (registration)
    Import of registerUtilityTools from utilities module.
    import { registerUtilityTools } from './tools/utilities.js'
  • Full handler implementation of the import_postman_environment tool: reads a Postman environment JSON file, validates it, parses variables (preferring currentValue over value), creates the environment via storage, optionally activates it, and returns a success/error response.
    server.tool(
      'import_postman_environment',
      'Importa un Postman Environment (JSON) como entorno local. Soporta variables con valores initial/current.',
      {
        file: z.string().describe('Ruta al archivo .postman_environment.json exportado de Postman'),
        name: z
          .string()
          .optional()
          .describe('Nombre para el entorno (default: usa el nombre del archivo Postman)'),
        overwrite: z
          .boolean()
          .optional()
          .describe('Sobreescribir si ya existe un entorno con el mismo nombre (default: false)'),
        activate: z
          .boolean()
          .optional()
          .describe('Activar el entorno importado como entorno activo (default: false)'),
      },
      async (params) => {
        try {
          const raw = await readFile(params.file, 'utf-8')
          const postmanEnv = JSON.parse(raw)
    
          if (!postmanEnv.values || !Array.isArray(postmanEnv.values)) {
            return {
              content: [
                {
                  type: 'text' as const,
                  text: 'Error: El archivo no parece ser un Postman Environment válido. Falta la propiedad "values".',
                },
              ],
              isError: true,
            }
          }
    
          const envName = params.name ?? postmanEnv.name ?? 'postman-import'
          const overwrite = params.overwrite ?? false
    
          const existing = await storage.getEnvironment(envName)
          if (existing && !overwrite) {
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Error: Ya existe un entorno '${envName}'. Usa overwrite: true para sobreescribir.`,
                },
              ],
              isError: true,
            }
          }
    
          // Parse variables — prefer currentValue over value (Postman v2.1 uses both)
          const variables: Record<string, string> = {}
          for (const v of postmanEnv.values) {
            if (!v.key) continue
            if (v.enabled === false) continue
            variables[v.key] = String(v.currentValue ?? v.value ?? '')
          }
    
          const now = new Date().toISOString()
          await storage.createEnvironment({
            name: envName,
            variables,
            createdAt: now,
            updatedAt: now,
          })
    
          if (params.activate) {
            await storage.setActiveEnvironment(envName)
          }
    
          const lines: string[] = [
            `Postman Environment "${envName}" importado (${Object.keys(variables).length} variables).`,
          ]
          if (params.activate) lines.push('Entorno activado como activo.')
    
          return {
            content: [{ type: 'text' as const, text: lines.join('\n') }],
          }
        } catch (error) {
          const message = error instanceof Error ? error.message : String(error)
          return {
            content: [{ type: 'text' as const, text: `Error: ${message}` }],
            isError: true,
          }
        }
      },
    )
  • Input schema for import_postman_environment: file (string, required), name (string, optional), overwrite (boolean, optional, default false), activate (boolean, optional, default false).
    {
      file: z.string().describe('Ruta al archivo .postman_environment.json exportado de Postman'),
      name: z
        .string()
        .optional()
        .describe('Nombre para el entorno (default: usa el nombre del archivo Postman)'),
      overwrite: z
        .boolean()
        .optional()
        .describe('Sobreescribir si ya existe un entorno con el mismo nombre (default: false)'),
      activate: z
        .boolean()
        .optional()
        .describe('Activar el entorno importado como entorno activo (default: false)'),
    },
  • Function signature registerUtilityTools that groups all utility tool registrations including import_postman_environment.
    export function registerUtilityTools(server: McpServer, storage: Storage): void {
Behavior3/5

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

The description adds the behavioral detail that it supports variables with initial/current values, which is not in the schema. However, it does not disclose other behaviors like side effects, validation, or permissions. Since no annotations exist, the description provides minimal extra context.

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

Conciseness5/5

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

The description is two concise sentences, front-loading the core purpose and adding a key feature. No wasted words.

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 that the schema fully documents parameters and there is no output schema, the description adequately covers the tool's purpose and key feature. It does not mention that it creates a local environment, but that is implied by the context of sibling tools. Nearly complete for the complexity.

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?

Schema coverage is 100%, and each parameter has a clear description. The description adds a small detail about variable support but does not enhance understanding of the parameters beyond the schema. Baseline 3 is appropriate.

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?

The description clearly states the verb ('Importa') and resource ('Postman Environment (JSON) como entorno local'), and distinguishes from siblings like env_create or import_environment by specifying the Postman format and support for initial/current variables.

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?

No guidance is provided on when to use this tool versus alternatives like import_environment or env_create. The description does not mention prerequisites, compatibility, or exclusion cases.

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/cocaxcode/api-testing-mcp'

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