EdgeMind-MCP-Story
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@EdgeMind-MCP-StoryGenerate a short sci-fi story about a robot rebellion"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
EdgeMind-MCP-Story
This project is part of the Day 2 task in the course "LLMs in Edge Computing". It provides a beginner-friendly Model Context Protocol (MCP) server that connects an LLM client to a local instance of LM Studio to generate and save creative writing stories.
1. Project Overview
EdgeMind-MCP-Story is a Python-based MCP server that exposes a custom tool, generate_story. When called by an MCP-compatible client, this tool takes a story topic and optional filename, constructs a creative writing prompt, sends it to a locally running model inside LM Studio, and automatically saves the generated story as a .txt file inside a local stories/ directory.
This allows you to leverage powerful, offline language models running on edge devices (like your local PC) directly within MCP-compatible developer tools, assistants, and IDE integrations.
Related MCP server: Claude-LMStudio-Bridge
2. Architecture
Below is the execution flow of how the model context protocol, the client, and the local server interact:
User (Input Topic & Filename)
↓
MCP Client (e.g., Claude Desktop, Inspector, Cursor)
↓
MCP Server (server.py via stdio)
↓
LM Studio Local API (http://localhost:1234/v1/chat/completions)
↓
Local Language Model (running on your PC)
↓
Generated Story (returned to Server)
↓
stories/story.txt (written locally in UTF-8)3. Requirements
To run this project, make sure you have:
Operating System: Windows 10/11
Python: Python 3.10 or higher installed (with
pipand virtual environment support)LM Studio: A local installer downloaded and configured on your PC
Local Language Model: A downloaded GGUF chat or instruct model inside LM Studio (e.g.,
Llama-3-8B-Instruct,Qwen-2.5-7B-Instruct,Phi-3-mini, etc.)MCP Host/Client: An MCP-compatible client (such as Claude Desktop, Cursor, or the MCP Inspector tool)
4. Installing Dependencies
Follow these steps to set up a clean Python virtual environment and install the required dependencies:
Open PowerShell or Command Prompt in the project directory:
cd c:\Users\koppa\Desktop\EdgeMind-MCP-StoryCreate a virtual environment:
python -m venv .venvActivate the virtual environment:
On Windows (Command Prompt):
.venv\Scripts\activateOn Windows (PowerShell):
.venv\Scripts\Activate.ps1
Install the required packages:
pip install -r requirements.txt
5. Setting Up LM Studio
Ensure your local model server is running before attempting to use the MCP tool:
Open LM Studio on your Windows PC.
Go to the Search / Discover tab (magnifying glass) and download a suitable local chat/instruct model (e.g., Qwen-2.5-7B-Instruct, Llama-3-8B-Instruct).
Go to the Developer / Local Server tab (the double-arrows icon
<->or server icon on the left sidebar).Load your downloaded model using the drop-down menu at the top.
Check the Port configuration (default is
1234).Click the Start Server button.
Verify that the console logs show
Local server listening on port 1234.Important: Look at the top of the screen or in the server logs and copy the exact model identifier (e.g.
lmstudio-community/Meta-Llama-3-8B-Instruct-GGUForqwen2.5-7b-instruct). You will need this for configuration.
6. Configure Environment Variables
Before starting the server, you must specify which model the server should instruct LM Studio to run.
Option A: System Environment Variables (Windows)
Run these commands in your terminal before running the server:
Command Prompt:
set LM_STUDIO_BASE_URL=http://localhost:1234/v1 set LM_STUDIO_MODEL=<your-copied-model-identifier>PowerShell:
$env:LM_STUDIO_BASE_URL="http://localhost:1234/v1" $env:LM_STUDIO_MODEL="<your-copied-model-identifier>"
Option B: Local .env File (Easiest)
Create a file named .env in the project root directory (c:\Users\koppa\Desktop\EdgeMind-MCP-Story\.env) and add the following content:
LM_STUDIO_BASE_URL=http://localhost:1234/v1
LM_STUDIO_MODEL=your-copied-model-identifierReplace your-copied-model-identifier with the exact name you copied in Section 5.
7. Running the MCP Server
You can start the MCP server directly using:
python server.pyNote: Because MCP servers use standard input/output (stdio) transport for communication with clients, running it directly in the terminal will not show a web UI or accept keyboard commands. It will wait silently for JSON-RPC messages from a client.
To stop the server, press Ctrl + C.
7.1 Running Offline Tests
To verify the logic of the server (such as filename sanitization, error responses, and mock LM Studio integration) offline, run:
python test_server.pyThis runs the automated unit tests in test_server.py and ensures everything is functioning properly without needing a live LM Studio connection.
8. Connecting the MCP Server to an MCP Client
To use the tool with an actual LLM, you need to configure an MCP client to launch the server.
Example: Claude Desktop
To add this server to the Claude Desktop application, open your Claude configuration file (located at %APPDATA%\Claude\claude_desktop_config.json) and add this configuration:
{
"mcpServers": {
"edgemind-story-writer": {
"command": "python",
"args": [
"c:/Users/koppa/Desktop/EdgeMind-MCP-Story/server.py"
],
"env": {
"LM_STUDIO_BASE_URL": "http://localhost:1234/v1",
"LM_STUDIO_MODEL": "<your-model-identifier-here>"
}
}
}
}Note: If you configured environment variables via a .env file inside the directory, you do not need to add the "env" block in the JSON file. Be sure to restart Claude Desktop after modifying this configuration.
9. Using the Tool
When connected, the MCP client gains access to the tool generate_story.
Arguments:
topic(string, required): The core concept or prompt for your story.filename(string, optional): A custom filename for the output file (e.g.mysterious_device.txt). If left blank, a safe filename will be automatically created based on the topic.
Example Prompt:
"Write a story about: A student discovers a mysterious device inside his college laboratory."
The client will automatically route this to the generate_story tool.
10. Output
All successfully written stories are stored inside the stories/ directory:
stories/
└── mysterious_device.txtThe server saves files using UTF-8 encoding. The output response returned to your MCP client will contain:
A confirmation that the story was generated by your local model.
The exact relative path where it was saved.
The topic of the story.
The file size and word count details.
11. Troubleshooting
1. "Error: Could not reach LM Studio at..."
Cause: LM Studio is not running, or the Local Server has not been started.
Solution: Open LM Studio, go to the Local Server tab, and verify that the server is started and listening on the port configured in
LM_STUDIO_BASE_URL(usually1234).
2. "Error: The environment variable 'LM_STUDIO_MODEL' is not set"
Cause: The server doesn't know which model to query.
Solution: Ensure you have defined
LM_STUDIO_MODELin your terminal environment, or created a.envfile with the model name in the project directory.
3. "Error: LM Studio returned HTTP status 400 (or other api error)"
Cause: The model name defined in
LM_STUDIO_MODELdoes not match the model currently loaded in LM Studio.Solution: Double-check the spelling of the model identifier at the top of the LM Studio window. Set it exactly as shown.
4. "Error: Cannot create or access the 'stories' folder"
Cause: Python does not have write permissions to the project directory.
Solution: Run terminal as Administrator or verify folder permissions in Windows.
12. Project Architecture
The project contains only the files required to run, keeping it simple and easy to demonstrate:
server.py: The core application file. Contains the MCP server instantiation, configuration validation, thegenerate_storytool, filename security sanitization, HTTP request payload creation, and local file storage logic.test_server.py: Automated unit tests for verifying filename sanitization, input validation, and mocked API interaction offline.requirements.txt: List of Python external dependencies required to run the server.stories/: Directory where all generated story text files will be written..gitignore: Tells Git to track the project files while ignoring local environment variables, Python cache directories, and generated story txt outputs.README.md: This guide.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityFmaintenanceAn MCP server that allows Claude to interact with local LLMs running in LM Studio, providing access to list models, generate text, and use chat completions through local models.13
- Alicense-qualityFmaintenanceA simple MCP server that enables Claude to communicate with locally running LLM models via LM Studio.9MIT
- Alicense-qualityFmaintenanceA token-saving MCP server that coordinates automated writing workflows between Obsidian vaults and LMStudio or Gemini free API, with automatic fallback to Gemini when LMStudio is unavailable.3MIT
- Flicense-qualityBmaintenanceA proof-of-concept MCP server that enables LLMs to read local text files and fetch real-time weather data through external tools.
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Person-owned, portable AI memory as a remote MCP server, readable and writable by any MCP client.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kopparapubalaji/VTU25526_EdgeMind-MCP-Story'
If you have feedback or need assistance with the MCP directory API, please join our Discord server