Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@graphai/mcp_agent

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphai/mcp_agent

Model Context Protocol

latest
npmnpm
Version
0.0.4
Version published
Weekly downloads
77
-41.67%
Maintainers
2
Weekly downloads
 
Created
Source

@graphai/mcp_agent for GraphAI

Model Context Protocol

Install

yarn add @graphai/mcp_agent

Configuring each service via mcpConfig

Each service is defined as a pair of command and args. This pattern can be extended to other applications as well.

export const mcpConfig = {
  filesystem: {
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-filesystem", path],
  },
  filesystem2: {
    command: __dirname + "/../../../node_modules/@modelcontextprotocol/server-filesystem/dist/index.js",
    args: [path],
  },
};

Initializing MCP and connecting to the server

MCP must be started before running GraphAI. Since the startup time may vary, it’s recommended to include a waiting period to ensure the server is ready. If GraphAI is run before MCP finishes initializing, the list of tools might be returned as empty.

The function that initializes MCP returns mcpClients. Since mcpClients is required when calling MCP, it is passed as a config to the GraphAI instance. It is also needed when closing the connection to the MCP server.

  const mcpClients = await mcpInit(mcpConfig);
  await setTimeout(2000);

Pass the client to the GraphAI instance.

When creating a GraphAI instance, mcpClients is passed via the config. Since MCP is divided into multiple agents, mcpClients is provided globally (although it's also possible to pass it individually).

  const graphai = new GraphAI(graphData, agents, { config: { global: { mcpClients } } });

Disconnecting from the MCP server

Be sure to explicitly disconnect from the MCP server when your batch job or server (e.g., Express) shuts down.

  await setTimeout(500);
  mcpClose(mcpClients);

Usage

import { GraphAI } from "graphai";
import { mcpResourceAgent, mcpResourcesAgent, mcpToolsCallAgent, mcpToolsListAgent } from "@graphai/mcp_agent";

const agents = { mcpResourceAgent, mcpResourcesAgent, mcpToolsCallAgent, mcpToolsListAgent };

const graph = new GraphAI(graph_data, agents);
const result = await graph.run();

Agents description

  • mcpResourceAgent - Model Context Protocol Resource Agent
  • mcpResourcesAgent - Model Context Protocol Resources Agent
  • mcpToolsCallAgent - Model Context Protocol Tools/Call Agent
  • mcpToolsListAgent - Model Context Protocol Tools/List Agent

Input/Output/Params Schema & samples

  • mcpResourceAgent
  • mcpResourcesAgent
  • mcpToolsCallAgent
  • mcpToolsListAgent

Input/Params example

  • mcpResourcesAgent
{
  "inputs": {},
  "params": {}
}
  • mcpToolsCallAgent
{
  "inputs": {
    "tools": {
      "name": "filesystem--list_directory",
      "arguments": {
        "path": "/home/runner/work/graphai-agents/graphai-agents/protocol/mcp-agent/lib/../tests/sample"
      }
    }
  },
  "params": {}
}
{
  "inputs": {
    "tools": {
      "name": "filesystem--list_directory",
      "arguments": {
        "path": "/home/runner/work/graphai-agents/graphai-agents/protocol/mcp-agent/lib/../tests/sample"
      }
    }
  },
  "params": {
    "mcpClientsKey": "key"
  }
}
  • mcpToolsListAgent
{
  "inputs": {},
  "params": {
    "services": [
      "filesystem"
    ]
  }
}

FAQs

Package last updated on 11 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts