hackerinheels /
multipleMCPServerWithPythonHost
This repository contains a python implementation of an MCP Host which is capable of running several MCP Servers with SSE protocol
27/100 healthLoading repository data…
radial-hks / repository
MCPServer is a Python-based server that leverages Alibaba's FunASR library to provide speech processing services through the FastMCP framework.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
MCPServer is a Python-based server that leverages Alibaba's FunASR library to provide speech processing services through the FastMCP framework. It offers tools for:
The server is designed to be extensible and allows for dynamic loading and switching of ASR and VAD models.
MODELSCOPE_API_TOKEN environment variable.export MODELSCOPE_API_TOKEN="YOUR_TOKEN_HERE"Clone the Repository (if applicable):
If this server is part of a larger repository, clone it. Otherwise, ensure you have the MCPServer directory and its contents.
Create and Activate a Virtual Environment (Recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Install Dependencies:
Navigate to the MCPServer directory (the one containing this README and server.py).
Install the required packages:
pip install -r requirements.txt
This will install fastmcp, funasr, and their dependencies, including PyTorch (CPU version by default if not specified otherwise by FunASR's direct dependencies). If you have specific PyTorch needs (e.g., a GPU version), it's recommended to install PyTorch manually before running the command above, following instructions from the official PyTorch website.
MCPServer directory.uvicorn main:app --host 0.0.0.0 --port 9000
http://0.0.0.0:9000. On the first run, FunASR will download the default ASR and VAD models, which may take some time.MCPServer: http://0.0.0.0:9000/sse
You can interact with these tools using any MCP client (e.g., mcp_client or via HTTP requests). The server provides the following tools:
validate_audio_filefile_path (str, required): Path to the audio file.{
"status": "valid",
"message": "Audio file is valid.",
"details": {
"samplerate": 16000,
"channels": 1,
"duration": 10.5,
"formatted_duration": "00:10.500",
"format": "WAV",
"subtype": "PCM_16"
}
}
{
"status": "invalid",
"message": "Error: File not found at 'path/to/non_existent_audio.wav'.",
"details": null
}
start_speech_transcriptionaudio_path (str, required): Path to the audio file.model_name (str, optional): Specific ASR model to use for this task (e.g., a ModelScope ID). Overrides the server's current default ASR model. If the specified model is not already loaded with compatible settings, the server will attempt to load it using its default load parameters for that model or the instance's general default load parameters.model_generate_kwargs (dict, optional): Specific arguments for the ASR model's generate method (e.g., {"batch_size_s": 60, "hotword": "特定热词"}). These override any default generation arguments set in the server for the current ASR model.{
"task_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "processing_started",
"message": "Transcription task started and is now processing."
}
{
"task_id": null,
"status": "error",
"message": "Error: File at '/path/to/your/bad_audio.wav' is not a valid audio file or is corrupted. Details: <error from soundfile>",
"details": null
}
{
"task_id": null,
"status": "error",
"message": "Failed to switch to model 'non_existent_model_id'. Error: Error loading model 'non_existent_model_id': <actual error>"
}
get_transcription_task_statustask_id (str, required): The unique ID of the transcription task.{
"status": "processing",
"audio_path": "/path/to/your/audio.wav",
"model_used": "iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
"submitted_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00",
"details_from_validation": { /* ... audio details from validate_audio ... */ },
"model_generate_kwargs": {"batch_size_s": 300, "hotword": "魔搭"},
"processing_started_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00"
}
- **Example Return (Completed):**
```json
{
"status": "completed",
"audio_path": "/path/to/your/audio.wav",
"model_used": "iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
"submitted_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00",
"details_from_validation": { /* ... */ },
"model_generate_kwargs": { /* ... */ },
"processing_started_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00",
"result": [ /* ... actual transcription result ... */ ],
"completed_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00"
}
```
- **Example Return (Error - Task Not Found):**
```json
{
"status": "error",
"message": "Task ID not found."
}
```
get_transcription_resulttask_id (str, required): The unique ID of the transcription task.{
"task_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "completed",
"result": [
{
"text": "这是 一段 测试 文本",
"start": 120,
"end": 2850,
"timestamp": [[120, 300], [330, 500], [550, 900], [920, 1200]]
}
],
"completed_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00"
}
{
"task_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "processing",
"message": "Transcription not yet completed or has failed."
}
{
"task_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"status": "failed",
"message": "Transcription failed.",
"error_details": "Description of the error during transcription.",
"failed_at": "YYYY-MM-DDTHH:MM:SS.ffffff+00:00"
}
load_asr_modelmodel_name (str, required): The FunASR model identifier to load (e.g., a ModelScope ID).device (str, optional): Device to load the model on (e.g., "cpu", "cuda:0"). Uses instance default if None.model_load_kwargs (dict, optional): Specific arguments for loading the ASR model (e.g., {"ncpu": 2, "vad_model": "other-vad-id", "punc_model": "other-punc-id"}). These will be passed to funasr.AutoModel.{
"status": "success",
"message": "Model 'iic/speech_paraformer-large-en-16k-common-vocab10020' loaded successfully on cpu with load_kwargs: {'ncpu': 2, 'vad_model': 'fsmn-vad'}."
}
{
"status": "error",
"message": "Error loading model 'invalid-model-id': <FunASR or ModelScope error details>"
}
get_voice_activity_segmentsaudio_path (str, required): Path to the audio file.vad_model_name (str, optional): Specific VAD model to use. Overrides the server's current default VAD model.model_load_kwargs (dict, optional): Specific arguments for loading the VAD model if vad_model_name is specified and different from the currently loaded one.model_generate_kwargs (dict, optional): Specific arguments for the VAD model's generate method.{
"status": "success",
"segments": [ [100, 2500], [3000, 5500] ],
"audio_path": "path/to/your/audio.wav",
"vad_model_used": "damo/speech_fsmn_vad_zh-cn-16k-common-pytorch",
"generate_kwargs_used": {},
"audio_details": { /* ... audio properties ... */ }
}
- **Example Return (Error - VAD Processing Failed):**
```json
{
"status": "error",
"message": "VAD processing failed for 'path/to/audio.wav': <FunASR error details>",
"audio_path": "path/to/audio.wav",
"vad_model_used": "damo/speech_fsmn_vad_zh-cn-16k-common-pytorch"
}
```
load_vad_modelmodel_name (str, required): The FunASR VAD model identifier to load.device (str, optional): Device to load the model on. Uses instance default if None.ncpu (int, optional): Number of CPU threads if device is CPU. Uses instance default if None.model_load_kwargs (dict,Selected from shared topics, language and repository description—not editorial ratings.
hackerinheels /
This repository contains a python implementation of an MCP Host which is capable of running several MCP Servers with SSE protocol
27/100 healthaaabhijith13 /
This is just a sample MCP server creation with Python. This can be directly utilized by deploying this online.
42/100 health