
An MCP server that provides access to LLMs using the LlamaIndexTS library.

Features
This MCP server provides the following tools:
generate_code
: Generate code based on a description
generate_code_to_file
: Generate code and write it directly to a file at a specific line number
generate_documentation
: Generate documentation for code
ask_question
: Ask a question to the LLM

Installation
Installing via Smithery
To install LLM Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @sammcj/mcp-llm --client claude
Manual Install From Source
- Clone the repository
- Install dependencies:
npm install
- Build the project:
npm run build
- Update your MCP configuration
Using the Example Script
The repository includes an example script that demonstrates how to use the MCP server programmatically:
node examples/use-mcp-server.js
This script starts the MCP server and sends requests to it using curl commands.
Examples
Generate Code
{
"description": "Create a function that calculates the factorial of a number",
"language": "JavaScript"
}
Generate Code to File
{
"description": "Create a function that calculates the factorial of a number",
"language": "JavaScript",
"filePath": "/path/to/factorial.js",
"lineNumber": 10,
"replaceLines": 0
}
The generate_code_to_file
tool supports both relative and absolute file paths. If a relative path is provided, it will be resolved relative to the current working directory of the MCP server.
Generate Documentation
{
"code": "function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}",
"language": "JavaScript",
"format": "JSDoc"
}
Ask Question
{
"question": "What is the difference between var, let, and const in JavaScript?",
"context": "I'm a beginner learning JavaScript and confused about variable declarations."
}
License
[
{
"description": "Generate code based on a description",
"inputSchema": {
"properties": {
"additionalContext": {
"description": "Additional context or requirements for the code",
"type": "string"
},
"description": {
"description": "Description of the code to generate",
"type": "string"
},
"language": {
"description": "Programming language (e.g., JavaScript, Python, TypeScript)",
"type": "string"
}
},
"required": [
"description"
],
"type": "object"
},
"name": "generate_code"
},
{
"description": "Generate code and write it directly to a file at a specific line number",
"inputSchema": {
"properties": {
"additionalContext": {
"description": "Additional context or requirements for the code",
"type": "string"
},
"description": {
"description": "Description of the code to generate",
"type": "string"
},
"filePath": {
"description": "Path to the file where the code should be written",
"type": "string"
},
"language": {
"description": "Programming language (e.g., JavaScript, Python, TypeScript)",
"type": "string"
},
"lineNumber": {
"description": "Line number where the code should be inserted (0-based)",
"type": "number"
},
"replaceLines": {
"description": "Number of lines to replace (0 for insertion only)",
"type": "number"
}
},
"required": [
"description",
"filePath",
"lineNumber"
],
"type": "object"
},
"name": "generate_code_to_file"
},
{
"description": "Generate documentation for code",
"inputSchema": {
"properties": {
"code": {
"description": "Code to document",
"type": "string"
},
"format": {
"description": "Documentation format (e.g., JSDoc, Markdown)",
"type": "string"
},
"language": {
"description": "Programming language of the code",
"type": "string"
}
},
"required": [
"code"
],
"type": "object"
},
"name": "generate_documentation"
},
{
"description": "Ask a question to the LLM",
"inputSchema": {
"properties": {
"context": {
"description": "Additional context for the question",
"type": "string"
},
"question": {
"description": "Question to ask",
"type": "string"
}
},
"required": [
"question"
],
"type": "object"
},
"name": "ask_question"
}
]