cth1975/Ansys_Workbench_Scripting_MCP
If you are the rightful owner of Ansys_Workbench_Scripting_MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A beginner-friendly Model Context Protocol (MCP) server that demonstrates how to create and expose text resources and prompt templates.
Simple FastMCP Server
A beginner-friendly Model Context Protocol (MCP) server that demonstrates how to create and expose text resources and prompt templates. This is perfect for learning MCP fundamentals!
What is MCP?
Model Context Protocol (MCP) is a standardized way for AI assistants (like Claude) to access external resources and tools. Think of it as a bridge between AI models and your custom data or functionality.
What This Server Does
This simple server exposes two types of MCP capabilities:
1. Text Resources 📄
Static content that can be retrieved by AI assistants:
- Company Information: Basic company details
- Product Catalog: List of products and pricing
- API Documentation: REST API docs and guidelines
2. Prompt Templates 🎯
Reusable prompt templates that accept parameters:
- analyze_data: Generate data analysis prompts
- write_email: Create professional email templates
- code_review: Generate code review checklists
Quick Start
Option 1: Super Easy Launch 🚀 (Recommended for Beginners)
Use our automated launcher that starts everything for you:
# This will automatically start both the MCP server and MCP Inspector
python launcher.py
The launcher will:
- ✅ Check and install dependencies automatically
- 🚀 Start your MCP server in the background
- 🌐 Launch MCP Inspector in your browser
- 🔗 Show you exactly how to connect them
- 🧹 Clean up everything when you press Ctrl+C
That's it! The launcher handles everything automatically and gives you clear instructions.
Option 2: Manual Setup
If you prefer to understand each step or want more control:
1. Install Dependencies
First, make sure you have Python 3.8+ and Node.js installed, then:
# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
2. Test the Server
Run the server directly to make sure it starts without errors:
python server.py
The server will start and wait for MCP protocol messages. You should see it running (it won't print anything - that's normal!). Press Ctrl+C to stop it.
Testing with MCP Inspector
MCP Inspector is a web-based tool for testing MCP servers.
If Using the Launcher 🚀
If you used python launcher.py, everything is already set up! Just follow the connection instructions shown in your terminal.
Manual MCP Inspector Setup
If you're doing manual setup, here's how to connect MCP Inspector to your server:
1. Install MCP Inspector
# Install globally via npm
npm install -g @modelcontextprotocol/inspector
# Or run directly with npx (no installation needed)
npx @modelcontextprotocol/inspector
2. Start the Inspector
# If installed globally:
mcp-inspector
# Or with npx:
npx @modelcontextprotocol/inspector
This will open a web browser with the MCP Inspector interface.
3. Connect to Your Server
Current Running Setup (Copy & Paste Ready):
🌐 MCP Inspector URL: http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=3c4c9d201c44466984c7bb6950fa75ee1974b9c3576d2a533460dff2e736798a
In the MCP Inspector interface:
-
Transport Type: Select "stdio"
-
Command:
/Users/christopherhoughton/Dropbox/Code/Ansys_Workbench_Scripting_MCP/.venv/bin/python -
Args:
/Users/christopherhoughton/Dropbox/Code/Ansys_Workbench_Scripting_MCP/server.py -
Working Directory:
/Users/christopherhoughton/Dropbox/Code/Ansys_Workbench_Scripting_MCP -
Click "Connect"
Generic Setup (for other users):
In the MCP Inspector interface:
-
Transport Type: Select "stdio" (this is how our server communicates)
-
Command: Enter the full path to your server:
python /full/path/to/your/server.pyFor example:
python /Users/yourname/simple-mcp-server/server.py -
Working Directory: Set to your project directory:
/Users/yourname/simple-mcp-server -
Click "Connect"
4. Explore the Server
Once connected, you can:
Test Resources:
- Go to the "Resources" tab
- You'll see three resources listed:
text://company_infotext://product_catalogtext://api_docs
- Click on any resource to view its content
Test Prompts:
- Go to the "Prompts" tab
- You'll see three prompts:
analyze_datawrite_emailcode_review
- Select a prompt and fill in the parameters
- Click "Get Prompt" to see the generated prompt text
Understanding the Code
Server Structure
# 1. Import MCP libraries
from mcp.server import Server
from mcp.server.stdio import stdio_server
# 2. Create server instance
server = Server("simple-fastmcp-server")
# 3. Define handlers with decorators
@server.list_resources()
@server.read_resource()
@server.list_prompts()
@server.get_prompt()
# 4. Run the server
asyncio.run(main())
Key Concepts
- Resources: Static content identified by URIs (like
text://company_info) - Prompts: Template functions that accept parameters and return customized prompts
- Handlers: Functions decorated with
@server.decorator()that respond to MCP requests - stdio Transport: Communication method using standard input/output streams
Adding Your Own Content
Add a New Resource:
-
Add data to the
SAMPLE_DATAdictionary:SAMPLE_DATA["my_resource"] = "My custom content here" -
Add to the
list_resources()function:Resource( uri="text://my_resource", name="My Resource", description="Description of my resource", mimeType="text/plain" )
Add a New Prompt:
-
Add to
list_prompts():Prompt( name="my_prompt", description="What my prompt does", arguments=[ PromptArgument( name="parameter_name", description="What this parameter is for", required=True ) ] ) -
Add handling in
get_prompt():elif name == "my_prompt": param = arguments.get("parameter_name", "default_value") prompt_text = f"Custom prompt using {param}"
Troubleshooting
Common Issues:
-
"Command not found" in MCP Inspector
- Make sure you're using the full absolute path to your server.py file
- Ensure Python is in your PATH
-
"Connection failed"
- Check that your server runs without errors when started directly
- Verify all dependencies are installed
-
"Module not found" errors
- Make sure you've activated your virtual environment
- Run
pip install -r requirements.txtagain
Debug Mode
To see what's happening, you can add some logging to your server:
import logging
logging.basicConfig(level=logging.DEBUG)
Next Steps
Once you understand this basic server, you can:
- Add Tools: Extend the server to expose callable functions
- Connect to Databases: Read data from real databases instead of static dictionaries
- Add Authentication: Secure your server with API keys or tokens
- Deploy: Run your server in production environments
- Integrate: Connect your server to Claude Desktop or other MCP clients
Resources
Happy MCP building! 🚀