๐ง MCP (Model Context Protocol) Integration Guide
NeuroLink Universal AI Platform with External Server Connectivity
๐ Overviewโ
NeuroLink now supports the Model Context Protocol (MCP) for seamless integration with external servers and tools. This enables unlimited extensibility through the growing MCP ecosystem while maintaining NeuroLink's simple interface.
Enhanced MCP Integration with Factory Patternsโ
import { NeuroLink } from "@juspay/neurolink";
const neurolink = new NeuroLink();
// NEW: Enhanced MCP integration with generate()
const result = await neurolink.generate({
input: { text: "List files in current directory using MCP" },
provider: "google-ai",
disableTools: false, // Enable MCP tool usage
});
// Alternative approach using legacy method (backward compatibility)
const legacyResult = await neurolink.generate({
prompt: "List files in current directory using MCP",
provider: "google-ai",
disableTools: false,
});
What is MCP?โ
The Model Context Protocol is a standardized way for AI applications to connect to external tools and data sources. It enables:
- โ External Tool Integration - Connect to filesystem, databases, APIs, and more
- โ Standardized Communication - JSON-RPC 2.0 protocol over multiple transports
- โ Tool Discovery - Automatic discovery of available tools and capabilities
- โ Secure Execution - Controlled access to external resources
- โ Ecosystem Compatibility - Works with 65+ community servers
๐ Quick Startโ
1. Install Popular MCP Serversโ
# Install filesystem server for file operations
npx neurolink mcp install filesystem
# Install GitHub server for repository management
npx neurolink mcp install github
# Install database server for SQL operations
npx neurolink mcp install postgres
2. Test Connectivityโ
# Test server connectivity and discover tools
npx neurolink mcp test filesystem
# List all configured servers with status
npx neurolink mcp list --status
3. ๐ Programmatic Server Managementโ
NEW! Add MCP servers dynamically at runtime:
import { NeuroLink } from "@juspay/neurolink";
const neurolink = new NeuroLink();
// Add external servers dynamically
await neurolink.addExternalMCPServer("bitbucket", {
command: "npx",
args: ["-y", "@nexus2520/bitbucket-mcp-server"],
env: {
BITBUCKET_USERNAME: "your-username",
BITBUCKET_APP_PASSWORD: "your-token",
},
});
// Add database integration
await neurolink.addExternalMCPServer("database", {
command: "node",
args: ["./custom-db-server.js"],
env: { DB_CONNECTION: "postgresql://..." },
});
// Verify registration โ getMCPStatus() also triggers MCP initialization,
// so always call it before listMCPServers() to ensure the subsystem is ready.
const status = await neurolink.getMCPStatus();
console.log("Active servers:", status.totalServers);
const servers = await neurolink.listMCPServers();
console.log(
"Registered servers:",
servers.map((s) => s.name),
);
4. Execute Tools (Planned)โ
This feature is planned for a future release.
# Execute tools from connected servers (planned โ not yet implemented)
npx neurolink mcp exec filesystem read_file --params '{"path": "README.md"}'
npx neurolink mcp exec github create_issue --params '{"title": "New feature", "body": "Description"}'
๐ MCP CLI Commands Referenceโ
Server Managementโ
Install Popular Serversโ
neurolink mcp install <server>
Available servers:
filesystem- File and directory operationsgithub- GitHub repository managementpostgres- PostgreSQL database operationsbrave-search- Web search capabilitiespuppeteer- Browser automation
Example:
neurolink mcp install filesystem
# โ
Installed MCP server: filesystem
# ๐ก Test it with: neurolink mcp test filesystem
Add Custom Serversโ
neurolink mcp add <name> <command> [options]
Options:
--args- Command arguments (array)--transport- Transport type (stdio|sse|websocket|http)--url- URL for SSE/WebSocket/HTTP transport--headers- HTTP headers for authentication (JSON)--env- Environment variables (JSON)--cwd- Working directory
Examples:
# Add custom server with arguments
neurolink mcp add myserver "python /path/to/server.py" --args "arg1,arg2"
# Add SSE server
neurolink mcp add webserver "http://localhost:8080" --transport sse --url "http://localhost:8080/mcp"
# Add HTTP remote server with authentication
neurolink mcp add remote-api "https://api.example.com/mcp" --transport http --url "https://api.example.com/mcp" --headers '{"Authorization": "Bearer YOUR_TOKEN"}'
# Add server with environment variables
neurolink mcp add dbserver "npx db-mcp-server" --env '{"DB_URL": "postgresql://..."}'
List Configured Serversโ
neurolink mcp list [--status]
Example output:
๐ Configured MCP servers (2):
๐ง filesystem
Command: npx -y @modelcontextprotocol/server-filesystem /
Transport: stdio
โ filesystem: โ
Available
๐ง github
Command: npx @modelcontextprotocol/server-github
Transport: stdio
โ github: โ Not available
Test Server Connectivityโ
neurolink mcp test <server>
Example output:
๐ Testing MCP server: filesystem
โ โ
Connection successful!
๐ Server Capabilities:
Protocol Version: 2024-11-05
Tools: โ
Supported
๐ ๏ธ Available Tools:
โข read_file: Read file contents from filesystem
โข write_file: Create/overwrite files
โข edit_file: Make line-based edits
โข create_directory: Create directories
โข list_directory: List directory contents
+ 6 more tools...
Remove Serversโ
neurolink mcp remove <server>
โ๏ธ Configurationโ
External Server Configurationโ
External MCP servers are configured in .mcp-config.json:
{
"mcpServers": {
"filesystem": {
"name": "filesystem",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/"],
"transport": "stdio"
},
"github": {
"name": "github",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"transport": "stdio"
},
"custom": {
"name": "custom",
"command": "python",
"args": ["/path/to/server.py"],
"transport": "stdio",
"cwd": "/project/directory"
}
}
}
Who loads .mcp-config.json, and whenโ
A project config names commands to run and URLs to connect to, so a directory is not a trust boundary: a cloned repository's .mcp-config.json must not run its servers with your credentials just because you ran something inside it.
SDK. new NeuroLink() never reads the working directory's file on its own. Name the file, or opt into the directory, in the constructor:
// Load a specific file (relative paths resolve against the working directory)
const neurolink = new NeuroLink({
mcp: { configPath: "./config/mcp-servers.json" },
});
// Load <cwd>/.mcp-config.json โ only for a directory you control
const trusted = new NeuroLink({ mcp: { trustProjectConfig: true } });
Servers added with addExternalMCPServer() / addInMemoryMCPServer() are unaffected. The legacy ProviderRegistry.setOptions({ enableManualMCP: true }) switch is now honoured too: set after construction, it re-enables the old working-directory discovery for that process.
CLI. neurolink still discovers ./.mcp-config.json, but loads it only after you have trusted that exact content. The file's SHA-256 is recorded in ~/.neurolink/trusted-mcp-configs.json (0600, directory 0700); a file that changes has to be trusted again.
- In a terminal, the first tool-enabled command shows the servers (names, commands, URLs,
envkey names โ never values) and asksTrust this file and start these servers? [y/N]. - Non-interactively (CI, pipes), an untrusted file is refused with exit status 1 at the moment it would load, with the same summary. Decide with one of:
neurolink generate "โฆ" --trust-mcp-configorNEUROLINK_TRUST_MCP_CONFIG=1โ trust and record the hash;NEUROLINK_TRUST_MCP_CONFIG=0โ run without the project config;--disable-toolsโ no MCP server is needed.
neurolink --help,--version, and any command that never initialises MCP are not affected.
${VAR} referencesโ
${NAME} in a server's env and args is replaced with process.env.NAME. Only names matching ^[A-Z][A-Z0-9_]*$ are expanded; anything else is left as written. ${NAME} is never expanded in headers or url โ those values travel to a remote host, so a reference there would send the variable's value off the machine. A ${โฆ} left in a header is sent literally and logged as a warning.
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" }
}
}
}
What a stdio server inheritsโ
A spawned server receives the MCP SDK's minimal default environment (HOME, PATH, SHELL, TERM, USER, LOGNAME on POSIX) plus its own env. It no longer receives the whole parent process.env, so provider keys and OAuth tokens held by the host do not reach an npx -y โฆ server unless you pass them through: "env": { "OPENAI_API_KEY": "${OPENAI_API_KEY}" }. A server that genuinely needs everything can set "inheritParentEnv": true.
Transport URLsโ
For http, sse and websocket servers the URL must use https: / wss: unless the host is loopback (localhost, 127.0.0.0/8, ::1), and the host must not be โ or resolve to โ a private, link-local, CGNAT or cloud-metadata address. A server on your own network opts out per entry with "allowPrivateNetwork": true, which also permits plaintext http: / ws: to private addresses; public hosts always need TLS. The WebSocket transport cannot send headers or auth (the handshake carries none), so a WebSocket server configured with either fails to connect instead of connecting unauthenticated โ use http or sse for authenticated servers.
Environment Variablesโ
Set these in your .env file for server authentication (the CLI loads .env; the SDK does not โ see Environment Variables):
# Custom Server Configuration
CUSTOM_API_KEY=your-api-key
CUSTOM_ENDPOINT=https://api.example.com
๐ ๏ธ Available MCP Serversโ
Filesystem Serverโ
Purpose: File and directory operations
Installation: neurolink mcp install filesystem
Available Tools:
read_file- Read file contentswrite_file- Create or overwrite filesedit_file- Make line-based editscreate_directory- Create directorieslist_directory- List directory contentsdirectory_tree- Get recursive tree viewmove_file- Move/rename filessearch_files- Search for files by patternget_file_info- Get file metadata
GitHub Serverโ
Purpose: GitHub repository management
Installation: neurolink mcp install github
Available Tools:
create_repository- Create new repositoriessearch_repositories- Search public repositoriesget_file_contents- Read repository filescreate_or_update_file- Modify repository filescreate_issue- Create GitHub issuescreate_pull_request- Create pull requestsfork_repository- Fork repositories
PostgreSQL Serverโ
Purpose: Database operations
Installation: neurolink mcp install postgres
Available Tools:
read-query- Execute SELECT querieswrite-query- Execute INSERT/UPDATE/DELETE queriescreate-table- Create database tableslist-tables- List available tablesdescribe-table- Get table schema
Brave Search Serverโ
Purpose: Web search capabilities
Installation: neurolink mcp install brave-search
Available Tools:
brave_web_search- Search the webbrave_local_search- Search for local businesses
Puppeteer Serverโ
Purpose: Browser automation
Installation: neurolink mcp install puppeteer
Available Tools:
puppeteer_navigate- Navigate to URLspuppeteer_screenshot- Take screenshotspuppeteer_click- Click elementspuppeteer_fill- Fill formspuppeteer_evaluate- Execute JavaScript