MCP Server with factorial calculation tools
Project description
MCP-WXO Project
Project Setup
This project uses:
- Project Directory:
~/bob/mcp-wxo(/Users/amandawinkles/bob/mcp-wxo) - Python Virtual Environment:
~/wxo-adk/wxO-adk(/Users/amandawinkles/wxo-adk/wxO-adk) - Python Version: 3.13.12
Activating the Virtual Environment
To activate the virtual environment, run:
source ~/wxo-adk/wxO-adk/bin/activate
Or from the project directory:
source /Users/amandawinkles/wxo-adk/wxO-adk/bin/activate
Deactivating the Virtual Environment
To deactivate the virtual environment:
deactivate
Project Structure
This is the root directory for the MCP-WXO project. All project files should be placed here.
Factorial MCP Server
This project includes an MCP (Model Context Protocol) server with two mathematical tools for factorial calculations:
Tools
-
factorial_value: Calculates and returns the exact value of n! (factorial of n)
- Input: A non-negative integer
n - Output: The exact factorial value
- Example:
factorial_value(5)returns120
- Input: A non-negative integer
-
factorial_digits: Returns the number of decimal digits in n!
- Input: A non-negative integer
n - Output: The number of digits in n!
- Example:
factorial_digits(100)returns158 - Useful for very large factorials that are too big to display
- Input: A non-negative integer
Installation
-
Activate the virtual environment:
source ~/wxo-adk/wxO-adk/bin/activate
-
Install dependencies:
pip install -e .
Running the Server
To start the MCP server:
python server.py
The server will start and listen for MCP tool requests.
Testing
Run the test suite to verify the implementation:
pytest test_server.py -v
Usage Examples
Using factorial_value
# Calculate 5!
factorial_value(5) # Returns: 120
# Calculate 10!
factorial_value(10) # Returns: 3628800
# Calculate 20!
factorial_value(20) # Returns: 2432902008176640000
Using factorial_digits
# Get digit count for 5!
factorial_digits(5) # Returns: 3 (because 5! = 120 has 3 digits)
# Get digit count for 100!
factorial_digits(100) # Returns: 158
# Get digit count for 1000!
factorial_digits(1000) # Returns: 2568
Implementation Details
- Both tools share a common helper function
calculate_factorial()to avoid code duplication factorial_valueuses Python's built-inmath.factorial()for exact computationfactorial_digitsuses logarithms for efficient calculation without computing the full factorial- Comprehensive error handling for negative numbers and invalid input types
- Full test coverage with pytest
Error Handling
Both tools validate input and raise appropriate errors:
TypeError: If the input is not an integerValueError: If the input is a negative number (factorial is undefined for negative numbers)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_wxo-0.1.0.tar.gz.
File metadata
- Download URL: mcp_wxo-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f964f20bfc5e69023ce85341e824fba98ad3b5a1c4605b7c8a0f3870873c9676
|
|
| MD5 |
75ed7d8f414f8e706f7fb381c32ea643
|
|
| BLAKE2b-256 |
44d092b5089acc16ba041c1613dee985785e5fbb1046ef062317697e581698bd
|
File details
Details for the file mcp_wxo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_wxo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e83527cef52b8ba05e2dbbb4643c9234e59e500b531526e0deec3a641a7bc7f
|
|
| MD5 |
be67d81f626438b0065a6a9fcc8fb890
|
|
| BLAKE2b-256 |
07f1db3880df27bb4315dca8480d4aa336a3dfd7a741403dc2313b34cb8c0a0a
|