1. Conduid
  2. Agents
  3. Mimory MCP Focus Langchainjs
MCP server · Agents

Mimory MCP Focus Langchainjs

Focus-enforcing wrapper for LangChain MCP clients

Unclaimed agents
37Low

Scored 6 months ago · breakdown

About Mimory MCP Focus Langchainjs

Mimory MCP Focus Langchainjs is an MCP server in the Agents category: focus-enforcing wrapper for LangChain MCP clients.

Install

Claude Code
claude mcp add mimory-mcp-focus-langchainjs -- npx -y mimory-mcp-focus-langchainjs
npx
npx -y mimory-mcp-focus-langchainjs

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Mimory MCP Focus Langchainjs

Powered by Claude · Grounded in docs

I know everything about Mimory MCP Focus Langchainjs. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.

5 checks have not been run yet.

README

mimory-mcp-focus-langchainjs

npm version

A focus-enforcing wrapper for LangChain MCP (Model Context Protocol) clients that allows you to restrict which tools and parameters can be used by AI agents, providing enhanced security and control over MCP tool access.

Features

  • Tool Restriction: Limit which MCP tools are available to your AI agents
  • Parameter Validation: Restrict parameter values using simple patterns or ranges
  • Multi-Server Support: Manage focus configurations across multiple MCP servers
  • LangChain Integration: Seamless integration with LangChain's MCP adapters
  • TypeScript Support: Full TypeScript definitions for better development experience
  • Flexible Configuration: Support for both simple and composite focus patterns

Installation

npm install mimory-mcp-focus-langchainjs

Peer Dependencies

This package requires the following peer dependencies:

npm install @langchain/mcp-adapters @mimory/mim-mcp-focus-js

Quick Start

import { FocusMultiServerMCPClient } from 'mimory-mcp-focus-langchainjs';

// Define MCP server connections
const connections = {
  everything: {
    transport: "stdio",
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-everything"]
  }
};

// Configure focus restrictions
const focusConfigs = {
  everything: {
    focusTools: ["echo"], // Only allow echo tool
    focusParams: {
      message: ["hello", "world", "test"] // Restrict message values
    },
    focusType: "simple",
    strict: false
  }
};

// Create focus-enabled client
const client = new FocusMultiServerMCPClient(connections, focusConfigs);

// Get restricted tools
const tools = await client.getTools();
console.log("Available tools:", tools);

Focus Configuration Patterns

Simple Focus

Simple focus allows you to restrict tools and parameters across all tools:

const focusConfig = {
  focusTools: ["tool1", "tool2"],
  focusParams: {
    param1: ["value1", "value2"],
    param2: ["range:1-100"]
  },
  focusType: "simple",
  strict: false
};

Composite Focus

Composite focus allows different restrictions per tool:

const focusConfig = {
  focus: {
    tool1: {
      param1: ["value1", "value2"],
      param2: ["range:1-10"]
    },
    tool2: {
      param3: ["value3", "value4"]
    }
  },
  focusType: "composite",
  strict: true
};

API Reference

FocusMultiServerMCPClient

The main class that wraps LangChain's MultiServerMCPClient with focus functionality.

Constructor

constructor(
  connections?: Record<string, Connection>,
  focusConfigs?: Record<string, FocusConfig>
)

Methods

  • getTools(serverName?: string): Get tools from specified servers with focus applied
  • getClient(serverName: string): Get a focused MCP client for a specific server
  • close(): Close all connections and clean up
  • getServerFocusConfig(serverName: string): Get focus configuration for a server
  • setServerFocusConfig(serverName: string, focusConfig: FocusConfig): Set focus configuration for a server

Factory Functions

createFocusClientSimple

function createFocusClientSimple(
  connections: Record<string, Connection>,
  focusTools?: Record<string, FocusTools>,
  focusParams?: Record<string, FocusParams>,
  strict: boolean = false
): FocusMultiServerMCPClient

createFocusClientComposite

function createFocusClientComposite(
  connections: Record<string, Connection>,
  focus?: Record<string, FocusComposite>,
  strict: boolean = false
): FocusMultiServerMCPClient

Examples

Basic Tool Restriction

import { FocusMultiServerMCPClient } from 'mimory-mcp-focus-langchainjs';

const connections = {
  everything: {
    transport: "stdio",
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-everything"]
  }
};

const focusConfigs = {
  everything: {
    focusTools: ["echo"],
    focusParams: {
      message: ["hello", "world", "test"]
    },
    focusType: "simple",
    strict: false
  }
};

const client = new FocusMultiServerMCPClient(connections, focusConfigs);
const tools = await client.getTools();

// Use tools with LangChain agents
const tool = tools[0];
const result = await tool.invoke({ message: "hello" });

Multi-Server Setup

const connections = {
  everything: {
    transport: "stdio",
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-everything"]
  },
  time: {
    transport: "stdio",
    command: "python",
    args: ["-m", "mcp_server_time"]
  }
};

const focusConfigs = {
  everything: {
    focus: {
      echo: {
        message: ["hello", "world", "composite", "focus"]
      },
      add: {
        a: ["range:1-5"],
        b: ["range:1-5"]
      }
    },
    focusType: "composite",
    strict: false
  },
  time: {
    focusTools: ["get_current_time"],
    focusParams: {
      timezone: ["America/New_York", "Europe/London", "Asia/Tokyo"]
    },
    focusType: "simple",
    strict: false
  }
};

const client = new FocusMultiServerMCPClient(connections, focusConfigs);

Using with LangChain Agents

import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/core/agents";
import { FocusMultiServerMCPClient } from 'mimory-mcp-focus-langchainjs';

// Create focus-enabled client
const client = new FocusMultiServerMCPClient(connections, focusConfigs);
const tools = await client.getTools();

// Create LangChain agent with restricted tools
const model = new ChatOpenAI({ model: "gpt-4" });
const agent = await createReactAgent({
  llm: model,
  tools,
  messagesPlaceholder: "You are a helpful assistant with access to restricted tools."
});

// Use the agent
const result = await agent.invoke({
  input: "Echo the message 'hello'"
});

Supported MCP Servers

Everything MCP Server

A test server that implements various MCP features:

Setup:

npm install -g @modelcontextprotocol/server-everything@latest

Available Tools:

  • echo: Echo back input messages
  • add: Add two numbers together

Time MCP Server

Provides time and timezone conversion capabilities:

Setup:

pip install mcp-server-time

Available Tools:

  • get_current_time: Get current time in a specific timezone
  • convert_time: Convert time between timezones

Error Handling

The library provides comprehensive error handling for focus-related issues:

try {
  const result = await tool.invoke({ message: "forbidden" });
} catch (error) {
  if (error.name === 'FocusError') {
    console.log('Focus restriction violated:', error.message);
  } else {
    console.log('Other error:', error.message);
  }
}

Configuration Options

FocusConfig Interface

interface FocusConfig {
  focusTools?: FocusTools;           // Allowed tools
  focusParams?: FocusParams;         // Parameter restrictions
  focus?: FocusComposite;            // Composite focus configuration
  focusType?: 'simple' | 'composite'; // Focus type
  strict?: boolean;                  // Strict mode enforcement
}

Parameter Value Patterns

  • Exact values: ["value1", "value2"]
  • Ranges: ["range:1-100"] for numeric ranges
  • Wildcards: ["*"] to allow all values

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects

Support

For support, please open an issue on GitHub or contact us at oss@mimory.io.

Author

Travis McQueen - oss@mimory.io


This library is part of the mimory ecosystem, providing secure and controlled access to MCP tools for AI applications.

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About Mimory MCP Focus Langchainjs

How do I install Mimory MCP Focus Langchainjs?

Run claude mcp add mimory-mcp-focus-langchainjs -- npx -y mimory-mcp-focus-langchainjs, then add the server to your MCP client's configuration.

Is Mimory MCP Focus Langchainjs safe to use with an AI agent?

Its trust score is 37 out of 100 (low). It passes 1 of the 1 static security checks run so far. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Mimory MCP Focus Langchainjs still maintained?

Conduid hasn't recorded a commit date for this repository yet. Check the repository directly for recent activity.