ansari-project/ansari-mcp
If you are the rightful owner of ansari-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 henry@mcphub.com.
Ansari-MCP is a server designed to facilitate the use of the Ansari model context protocol, providing a robust framework for managing model interactions.
Ansari MCP Server
An MCP (Model Context Protocol) server that provides Islamic knowledge through the Ansari API. This server allows Claude Desktop, Claude Code, Cursor, and other MCP clients to answer Islamic questions with authentic sources from the Quran and Hadith.
Hosted Server
The Ansari MCP server is available as a hosted service at:
https://mcp.ansari.chat/mcp
You can use this URL directly in Claude Code or with adapters for Claude Desktop and Cursor (see setup instructions below).
Quick Start - Using the Hosted Server
The easiest way to use Ansari MCP is through our hosted server. No installation required!
Claude Desktop
-
Open Claude Desktop and click on your profile/name in the bottom left corner
-
Select "Settings" from the menu
-
Navigate to "Developer" tab and click "Edit Config"
-
This will open the
claude_desktop_config.json
file in your default text editor- macOS: Located at
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: Located at
%APPDATA%\Claude\claude_desktop_config.json
- macOS: Located at
-
Add this configuration:
{
"mcpServers": {
"ansari": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://mcp.ansari.chat/mcp"
]
}
}
}
- Restart Claude Desktop completely (Cmd+Q / Alt+F4 and reopen)
Claude Code
- Open your project in Claude Code
- Add to your
.claude.json
or global configuration:
{
"mcpServers": {
"ansari": {
"type": "http",
"url": "https://mcp.ansari.chat/mcp"
}
}
}
Visual Studio Code (with MCP Extension)
If you have an MCP extension installed in VS Code:
- Open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
- Run "MCP: Add Server..."
- Select "HTTP (HTTP or Server-Sent Events)"
- Enter URL:
https://mcp.ansari.chat/mcp
- Name it: "Ansari"
Cursor
Cursor supports HTTP MCP servers directly:
{
"mcpServers": {
"ansari": {
"type": "http",
"url": "https://mcp.ansari.chat/mcp"
}
}
}
Local Installation (Optional)
If you prefer to run the server locally:
Prerequisites
- Node.js (v18 or higher)
- npm
Installation Steps
- Clone the repository:
git clone https://github.com/ansari-project/ansari-mcp.git
cd ansari-mcp
- Install dependencies:
npm install
- Build the TypeScript code:
npm run build
Development
Building the Project
Important: After making ANY changes to the TypeScript source files in src/
, you MUST rebuild:
npm run build
Configuration
API Endpoint
By default, the server connects to:
https://staging-api.ansari.chat/api/v2/mcp-complete
You can override this with the --api-url
(or -u
) flag:
npm start -- --api-url https://custom-api.example.com/api/endpoint
Running the Server
Mode 1: stdio (for Claude Desktop & Claude Code)
This is the default mode for integration with Claude Desktop and Claude Code:
npm start
Mode 2: HTTP (for testing)
To run in HTTP mode for testing with curl or other HTTP clients:
npm start -- --http
The server will be available at: http://localhost:8089/mcp
Local Server Configuration
If you're running the server locally instead of using the hosted version:
Claude Desktop (Local)
{
"mcpServers": {
"ansari": {
"command": "node",
"args": ["/absolute/path/to/ansari-mcp/dist/server.js"],
"env": {}
}
}
}
Claude Code (Local)
{
"mcpServers": {
"ansari": {
"command": "node",
"args": ["/absolute/path/to/ansari-mcp/dist/server.js"],
"env": {}
}
}
}
Cursor (Local)
{
"mcpServers": {
"ansari": {
"command": "node",
"args": ["/absolute/path/to/ansari-mcp/dist/server.js"],
"env": {}
}
}
}
Note: Replace /absolute/path/to/ansari-mcp
with your actual installation path.
Usage
Once configured, you can ask Islamic questions in Claude Desktop or Claude Code:
- Start a new conversation
- The Ansari tool will be available automatically
- Ask Islamic questions naturally, for example:
- "What are the five pillars of Islam?"
- "What does the Quran say about charity?"
- "Explain the concept of Tawheed"
- "How many times is prayer mentioned in the Quran?"
Claude will use the Ansari tool to provide answers with authentic citations from the Quran and Hadith.
Testing
Test the API Connection Directly
# Create a test file
cat > test-api.mjs << 'EOF'
import { askAnsari } from './dist/ansari-service.js';
askAnsari('What is zakat?').then(console.log);
EOF
# Run the test
node test-api.mjs
Test with MCP Inspector
Install and run the MCP Inspector:
npx @modelcontextprotocol/inspector dist/server.js
This will open a web interface where you can test the tool interactively.
Test in HTTP Mode
- Start the server:
npm start -- --http
- The server will run at
http://localhost:8089/mcp
Troubleshooting
"Unexpected token" Error in Claude Desktop
Problem: You see MCP ansari: Unexpected token 'C', "Calling An"... is not valid JSON
Solution: This occurs when console.log statements interfere with the MCP protocol. The code should already have these removed, but if you add any debugging:
- Remove ALL
console.log()
statements - Remove ALL
console.error()
statements - Only pure JSON-RPC communication should go to stdout
Changes Not Taking Effect
Problem: You modified the code but changes aren't working
Solution: You MUST rebuild after every change:
npm run build
Claude Desktop Not Finding the Tool
Problem: The Ansari tool doesn't appear in Claude Desktop
Solutions:
- Verify the path in
claude_desktop_config.json
is absolute and correct - Ensure you ran
npm run build
successfully - Completely restart Claude Desktop (quit and reopen)
- Check the build output exists:
ls dist/server.js
Connection to API Fails
Problem: "Failed to fetch answer from Ansari API"
Solutions:
- Check your internet connection
- Verify the API is accessible:
curl https://staging-api.ansari.chat/api/v2/mcp-complete
- Try with a custom API URL if you have one
Build Errors
Problem: TypeScript compilation fails
Solution:
# Clean and rebuild
rm -rf dist/
npm run build
Project Structure
ansari-mcp/
āāā src/
ā āāā server.ts # Main MCP server implementation
ā āāā ansari-service.ts # Ansari API client service
āāā dist/ # Compiled JavaScript (generated by build)
ā āāā server.js # Compiled server
ā āāā ansari-service.js # Compiled service
āāā tmp/ # Temporary test files (git-ignored)
āāā package.json # Project dependencies and scripts
āāā tsconfig.json # TypeScript configuration
āāā README.md # This file
Important Notes
- Always rebuild after changes: Run
npm run build
after modifying ANY TypeScript files - No console output in stdio mode: Console statements will break the MCP protocol
- Use absolute paths: In Claude Desktop/Code configs, always use absolute paths
- Restart after config changes: Always restart Claude Desktop/Code after changing configuration
API Information
The Ansari API provides:
- Quranic verses with Arabic text and English translations
- Authentic Hadith with grading and sources
- Scholarly explanations based on classical Islamic texts
- Proper citations with chapter, verse, and hadith numbers
Support
For issues or questions:
- Check the Issues page
- API Documentation: https://staging-api.ansari.chat/redoc
- Contact the Ansari project team
License
[Your License Here]