Skip to main content
Glama
ssdeanx

Node.js Sandbox MCP Server

get_dependency_types

Fetch TypeScript definitions for npm packages to inspect APIs and types before running Node.js scripts with unfamiliar dependencies.

Instructions

Given an array of npm package names (and optional versions), fetch whether each package ships its own TypeScript definitions or has a corresponding @types/… package, and return the raw .d.ts text.

Useful whenwhen you're about to run a Node.js script against an unfamiliar dependency and want to inspect what APIs and types it exposes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dependenciesYes

Implementation Reference

  • The async handler function that processes an array of npm dependencies, fetches package metadata from npm registry and unpkg, checks for built-in types or @types packages, retrieves .d.ts contents, and returns results as JSON.
    export default async function getDependencyTypes({
      dependencies,
    }: {
      dependencies: { name: string; version?: string }[];
    }): Promise<McpResponse> {
      const results: {
        name: string;
        hasTypes: boolean;
        types?: string;
        typesPackage?: string;
        version?: string;
      }[] = [];
    
      for (const dep of dependencies) {
        const info: (typeof results)[number] = { name: dep.name, hasTypes: false };
        try {
          const pkgRes = await fetch(`https://registry.npmjs.org/${dep.name}`);
          if (pkgRes.ok) {
            const pkgMeta = (await pkgRes.json()) as any;
            const latestTag = pkgMeta['dist-tags']?.latest as string;
            const versionToUse = dep.version || latestTag;
            const versionData = pkgMeta.versions?.[versionToUse];
            // Check for in-package types
            if (versionData) {
              const typesField = versionData.types || versionData.typings;
              if (typesField) {
                const url = `https://unpkg.com/${dep.name}@${versionToUse}/${typesField}`;
                const contentRes = await fetch(url);
                if (contentRes.ok) {
                  info.hasTypes = true;
                  info.types = await contentRes.text();
                  info.version = versionToUse;
                  results.push(info);
                  continue;
                }
              }
            }
    
            // Fallback to @types package
            const sanitized = dep.name.replace('@', '').replace('/', '__');
            const typesName = `@types/${sanitized}`;
            const typesRes = await fetch(
              `https://registry.npmjs.org/${encodeURIComponent(typesName)}`
            );
            if (typesRes.ok) {
              const typesMeta = (await typesRes.json()) as any;
              const typesVersion = typesMeta['dist-tags']?.latest as string;
              const typesVersionData = typesMeta.versions?.[typesVersion];
              const typesField =
                typesVersionData?.types ||
                typesVersionData?.typings ||
                'index.d.ts';
              const url = `https://unpkg.com/${typesName}@${typesVersion}/${typesField}`;
              const contentRes = await fetch(url);
              if (contentRes.ok) {
                info.hasTypes = true;
                info.typesPackage = typesName;
                info.version = typesVersion;
                info.types = await contentRes.text();
              }
            }
          }
        } catch (e) {
          logger.info(`Failed to fetch type info for ${dep.name}: ${e}`);
        }
        results.push(info);
      }
    
      return { content: [textContent(JSON.stringify(results))] };
    }
  • Zod schema defining the input: an array of objects with 'name' (string, required) and 'version' (string, optional). Imported as getDependencyTypesSchema in server.ts.
    export const argSchema = {
      dependencies: z.array(
        z.object({
          name: z.string(),
          version: z.string().optional(),
        })
      ),
    };
  • src/server.ts:100-112 (registration)
    Registers the tool named 'get_dependency_types' on the MCP server, providing the tool name, description, input schema (getDependencyTypesSchema), and handler (getDependencyTypes).
    server.tool(
      'get_dependency_types',
      `
      Given an array of npm package names (and optional versions), 
      fetch whether each package ships its own TypeScript definitions 
      or has a corresponding @types/… package, and return the raw .d.ts text.
      
      Useful whenwhen you're about to run a Node.js script against an unfamiliar dependency 
      and want to inspect what APIs and types it exposes.
      `,
      getDependencyTypesSchema,
      getDependencyTypes
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does (fetches and returns .d.ts text) but lacks details on behavioral traits such as error handling (e.g., what happens if a package doesn't exist), performance (e.g., rate limits or timeouts), or side effects (e.g., whether it caches results or makes network calls). The description is functional but misses key operational 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 appropriately sized and front-loaded: the first sentence states the core functionality, and the second provides usage context. Every sentence earns its place with no redundant information, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's moderate complexity (fetching TypeScript definitions for dependencies), no annotations, no output schema, and low schema description coverage, the description is incomplete. It covers the purpose and usage well but lacks details on parameters, behavioral traits, and output format (beyond mentioning '.d.ts text'). This leaves gaps for an AI agent to fully understand how to invoke and interpret results.

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?

The input schema has 0% description coverage, so the description must compensate. It mentions 'array of npm package names (and optional versions)', which aligns with the 'dependencies' parameter in the schema. However, it doesn't explain the structure (e.g., that 'dependencies' is an array of objects with 'name' and optional 'version'), provide examples, or detail constraints (e.g., format of package names). This adds minimal semantic value beyond the bare schema.

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: 'fetch whether each package ships its own TypeScript definitions or has a corresponding @types/… package, and return the raw .d.ts text.' This specifies the verb (fetch/return), resource (TypeScript definitions), and output (raw .d.ts text). However, it doesn't explicitly distinguish this tool from its siblings (like ai_generate or run_js), which are unrelated but still siblings.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'Useful when you're about to run a Node.js script against an unfamiliar dependency and want to inspect what APIs and types it exposes.' This gives a specific scenario (inspecting dependencies before running a script) but doesn't explicitly state when not to use it or mention alternatives among the sibling tools, which are unrelated to dependency analysis.

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/ssdeanx/node-code-sandbox-mcp'

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