๐งช MCP Foundation Testing Guide
โ ๏ธ PLANNED FEATURE: This documentation describes features that are planned but not yet implemented. The
ContextManagerclass referenced in this guide does not currently exist in the codebase. The code examples are illustrative of the intended API design.
NeuroLink v1.3.0 MCP Foundation - Comprehensive guide for testing MCP functionality and adding custom MCP servers.
๐ฏ Current MCP Implementation Statusโ
โ What's Already Workingโ
- ๐ญ MCP Server Factory:
createMCPServer()with full validation - ๐ง Context Management: Rich context system with 15+ fields
- ๐ Tool Registry: Complete registration and execution system
- ๐ผ Tool Orchestration: Pipeline execution with error handling
- ๐ค AI Core Server: 3 production-ready AI tools
๐ What Needs CLI Integrationโ
The MCP Foundation is complete but not yet exposed via CLI commands. This guide shows both:
- Programmatic Testing (works now)
- CLI Integration (how to add it)
๐งช Testing MCP Foundation Programmaticallyโ
1. Basic MCP Server Creationโ
Create a test file to explore MCP functionality:
// test-mcp.ts (TypeScript; run with ts-node or compile first)
import { createMCPServer } from "@juspay/neurolink";
import {
NeuroLinkMCPTool,
NeuroLinkExecutionContext,
ToolResult,
} from "@juspay/neurolink";
// Create a custom MCP server
const testServer = createMCPServer({
id: "my-test-server",
title: "My Test Server",
description: "Testing custom MCP tools",
category: "custom",
visibility: "private",
});
// Add a simple tool
testServer.registerTool({
name: "hello-world",
description: "Simple hello world tool for testing",
execute: async (
params: any,
context: NeuroLinkExecutionContext,
): Promise<ToolResult> => {
console.log("Hello World tool executed!");
console.log("Context:", context.sessionId);
return {
success: true,
data: { message: `Hello, ${params.name || "World"}!` },
metadata: {
toolName: "hello-world",
timestamp: Date.now(),
},
};
},
});
console.log("Test server created:", testServer.id);
console.log("Available tools:", Object.keys(testServer.tools));
2. Testing with AI Core Serverโ
// test-ai-core.ts
import { aiCoreServer } from "@juspay/neurolink";
import { ContextManager } from "@juspay/neurolink";
async function testAICoreServer() {
// Create execution context
const context = ContextManager.createExecutionContext({
sessionId: "test-session-123",
userId: "test-user",
aiProvider: "openai",
environmentType: "development",
});
console.log("๐งช Testing AI Core Server...");
// Test text generation tool
try {
const result = await aiCoreServer.tools["generate"].execute(
{
prompt: "Write a haiku about AI",
temperature: 0.7,
maxTokens: 100,
},
context,
);
console.log("โ
Text Generation Result:", result);
} catch (error) {
console.error("โ Text Generation Error:", error);
}
// Test provider selection tool
try {
const providerResult = await aiCoreServer.tools["select-provider"].execute(
{
preferred: "openai",
requirements: {
streaming: true,
costEfficient: true,
},
},
context,
);
console.log("โ
Provider Selection Result:", providerResult);
} catch (error) {
console.error("โ Provider Selection Error:", error);
}
// Test provider status tool
try {
const statusResult = await aiCoreServer.tools[
"check-provider-status"
].execute(
{
includeCapabilities: true,
},
context,
);
console.log("โ
Provider Status Result:", statusResult);
} catch (error) {
console.error("โ Provider Status Error:", error);
}
}
testAICoreServer();
3. Testing Tool Registry and Orchestrationโ
// test-orchestration.ts
import { MCPRegistry } from "@juspay/neurolink";
import { ToolOrchestrator } from "@juspay/neurolink";
import { ContextManager } from "@juspay/neurolink";
import { aiCoreServer } from "@juspay/neurolink";
async function testOrchestration() {
// Initialize registry and orchestrator
const registry = new MCPRegistry();
const orchestrator = new ToolOrchestrator(registry);
// Register AI Core Server
registry.registerServer(aiCoreServer);
// Create execution context
const context = ContextManager.createExecutionContext({
sessionId: "orchestration-test",
environmentType: "development",
});
console.log("๐ผ Testing Tool Orchestration...");
// Execute single tool
try {
const result = await orchestrator.executeTool(
"neurolink-ai-core",
"generate",
{ prompt: "Explain quantum computing in one sentence", maxTokens: 50 },
context,
);
console.log("โ
Single Tool Execution:", result);
} catch (error) {
console.error("โ Single Tool Error:", error);
}
// Execute pipeline (sequential tools)
try {
const pipelineResult = await orchestrator.executePipeline(
[
{
serverId: "neurolink-ai-core",
toolName: "select-provider",
params: { preferred: "openai" },
},
{
serverId: "neurolink-ai-core",
toolName: "generate",
params: { prompt: "Write a technical joke", maxTokens: 100 },
},
],
context,
);
console.log("โ
Pipeline Execution:", pipelineResult);
} catch (error) {
console.error("โ Pipeline Error:", error);
}
// Get orchestrator statistics
const stats = orchestrator.getStatistics();
console.log("๐ Orchestrator Statistics:", stats);
}
testOrchestration();
๐จ Adding Custom MCP Serversโ
1. Creating a Development Tools Serverโ
// servers/dev-tools-server.ts
import { createMCPServer } from "@juspay/neurolink";
import { z } from "zod";
import type { NeuroLinkExecutionContext, ToolResult } from "@juspay/neurolink";
// Create development tools server
export const devToolsServer = createMCPServer({
id: "neurolink-dev-tools",
title: "NeuroLink Development Tools",
description: "Code generation, testing, and development utilities",
category: "development",
version: "1.0.0",
capabilities: [
"code-generation",
"test-creation",
"documentation",
"refactoring",
],
});
// Code Generation Tool
devToolsServer.registerTool({
name: "generate-component",
description: "Generate React/Vue/Svelte components with TypeScript",
inputSchema: z.object({
framework: z.enum(["react", "vue", "svelte"]),
componentName: z.string(),
props: z
.array(
z.object({
name: z.string(),
type: z.string(),
required: z.boolean().default(false),
}),
)
.optional(),
styling: z
.enum(["css", "scss", "styled-components", "tailwind"])
.optional(),
}),
execute: async (
params: any,
context: NeuroLinkExecutionContext,
): Promise<ToolResult> => {
const { framework, componentName, props = [], styling = "css" } = params;
// Generate component code based on framework
let componentCode = "";
if (framework === "react") {
const propsInterface =
props.length > 0
? `interface ${componentName}Props {\n${props.map((p) => ` ${p.name}${p.required ? "" : "?"}: ${p.type};`).join("\n")}\n}\n\n`
: "";
componentCode = `${propsInterface}export function ${componentName}(${props.length > 0 ? `props: ${componentName}Props` : ""}) {
return (
<div className="${componentName.toLowerCase()}">
<h1>${componentName} Component</h1>
{/* Add your component logic here */}
</div>
);
}`;
} else if (framework === "svelte") {
const scriptProps =
props.length > 0
? `<script lang="ts">\n${props.map((p) => ` export let ${p.name}: ${p.type}${p.required ? "" : " | undefined"};`).join("\n")}\n</script>\n\n`
: "";
componentCode = `${scriptProps}<div class="${componentName.toLowerCase()}">
<h1>${componentName} Component</h1>
<!-- Add your component markup here -->
</div>
<style>
.${componentName.toLowerCase()} {
/* Add your styles here */
}
</style>`;
}
return {
success: true,
data: {
code: componentCode,
framework,
componentName,
propsCount: props.length,
styling,
},
metadata: {
toolName: "generate-component",
serverId: "neurolink-dev-tools",
timestamp: Date.now(),
},
};
},
});
// Test Generation Tool
devToolsServer.registerTool({
name: "generate-tests",
description: "Generate unit tests for components or functions",
inputSchema: z.object({
testFramework: z.enum(["vitest", "jest", "playwright"]),
targetFile: z.string(),
functions: z.array(z.string()),
coverage: z.enum(["basic", "comprehensive"]).default("basic"),
}),
execute: async (
params: any,
context: NeuroLinkExecutionContext,
): Promise<ToolResult> => {
const { testFramework, targetFile, functions, coverage } = params;
const testTemplate = `import { describe, it, expect } from '${testFramework}';
import { ${functions.join(", ")} } from '${targetFile}';
${functions
.map(
(fn) => `describe('${fn}', () => {
it('should ${coverage === "comprehensive" ? "handle all edge cases" : "work correctly"}', () => {
// Test implementation for ${fn}
expect(${fn}).toBeDefined();
});
});`,
)
.join("\n\n")}`;
return {
success: true,
data: {
testCode: testTemplate,
testFramework,
functionsCount: functions.length,
coverage,
},
metadata: {
toolName: "generate-tests",
serverId: "neurolink-dev-tools",
timestamp: Date.now(),
},
};
},
});
console.log(
"[DevTools] Development Tools Server created with tools:",
Object.keys(devToolsServer.tools),
);
2. Creating a Content Creation Serverโ
// servers/content-server.ts
import { createMCPServer } from "@juspay/neurolink";
import { z } from "zod";
import type { NeuroLinkExecutionContext, ToolResult } from "@juspay/neurolink";
export const contentServer = createMCPServer({
id: "neurolink-content",
title: "NeuroLink Content Creation",
description: "Blog posts, documentation, and marketing content generation",
category: "content",
version: "1.0.0",
});
// Blog Post Generation Tool
contentServer.registerTool({
name: "generate-blog-post",
description: "Generate blog posts with SEO optimization",
inputSchema: z.object({
topic: z.string(),
audience: z.enum(["technical", "business", "general"]),
length: z.enum(["short", "medium", "long"]),
tone: z.enum(["professional", "casual", "educational"]),
includeSEO: z.boolean().default(true),
}),
execute: async (
params: any,
context: NeuroLinkExecutionContext,
): Promise<ToolResult> => {
// Use AI Core Server for content generation
const aiResult = (await context.toolChain?.includes("neurolink-ai-core"))
? { content: `Generated blog post about ${params.topic}...` }
: {
content: `Mock blog post about ${params.topic} for ${params.audience} audience`,
};
const metadata = {
wordCount:
params.length === "short"
? 500
: params.length === "medium"
? 1000
: 2000,
readingTime:
params.length === "short" ? 2 : params.length === "medium" ? 5 : 8,
seoOptimized: params.includeSEO,
};
return {
success: true,
data: {
content: aiResult.content,
...metadata,
topic: params.topic,
audience: params.audience,
},
metadata: {
toolName: "generate-blog-post",
serverId: "neurolink-content",
timestamp: Date.now(),
},
};
},
});
console.log(
"[Content] Content Creation Server created with tools:",
Object.keys(contentServer.tools),
);