A TypeScript client for interfacing with the Magisterium API.
Requires at least Node.js 12.20.0 given use of node-fetch (https://www.npmjs.com/package/node-fetch?activeTab=readme)
-
Install dependencies:
npm install
-
Set up your API key: Create a
.envfile in the project root and add your API key:MAGISTERIUM_API_KEY=your-actual-api-key-here
You have several options to compile the TypeScript code:
npx tscThis compiles the TypeScript files and outputs them to the dist/ directory.
npx tsc --target es2020 --module commonjs magisterium.tsThis creates magisterium.js in the current directory.
npx tsc magisterium.tsUses default TypeScript settings and creates magisterium.js in the current directory.
After compilation, you can run the code:
# If compiled with tsconfig.json (Method 1)
node dist/magisterium.js
# If compiled with Method 2 or 3
node magisterium.jsThis project includes an MCP server that provides a magisterium_query tool for AI assistants to query the Magisterium API directly.
npm run mcpThe MCP server provides a magisterium_query tool with the following parameters:
- query (required): The question or topic to ask about Catholic Church teaching
- model (optional): The model to use (default: "magisterium-1")
- return_related_questions (optional): Whether to return related questions (default: true)
{
"name": "magisterium_query",
"arguments": {
"query": "What does the Catholic Church teach about the Eucharist?",
"model": "magisterium-1",
"return_related_questions": true
}
}To use this MCP server with compatible AI assistants:
-
Claude Desktop: Add the server configuration to your
claude_desktop_config.json:{ "mcpServers": { "magisterium": { "command": "node", "args": ["--loader", "ts-node/esm", "mcp-magisterium.ts"], "cwd": "/path/to/magisterium", "env": { "MAGISTERIUM_API_KEY": "" } } } } -
Other MCP Clients: Use the provided
mcp-config.jsonas a reference for configuration.
The code makes a direct API call to the Magisterium API:
curl -X POST https://www.magisterium.com/api/v1/chat/completions \
-H "Authorization: Bearer $MAGISTERIUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magisterium-1",
"messages": [
{
"role": "user",
"content": "What is the Magisterium?"
}
],
"stream": True
}'