Maybe a little bit different, I asked an AI for using this MCP for local self-hosting.
Attached some quick samples:
import requests
import json
def query_gramps_mcp(prompt):
url = "http://localhost:8000/query"
headers = {"Content-Type": "application/json"}
data = {"prompt": prompt}
response = requests.post(url, headers=headers, json=data)
return response.json()
# Exemple
gramps_data = query_gramps_mcp("Find all ancestors of John Doe")
print(gramps_data)
via http
import subprocess
import json
def query_gramps_mcp_stdio(prompt):
process = subprocess.Popen(
["uv", "run", "python", "-m", "src.gramps_mcp.server", "stdio"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
cwd="/chemin/vers/gramps-mcp"
)
process.stdin.write(json.dumps({"prompt": prompt}) + "\n")
process.stdin.flush()
output = ""
while True:
line = process.stdout.readline()
if not line:
break
output += line
process.terminate()
return json.loads(output)
# Exemple
gramps_data = query_gramps_mcp_stdio("Find all ancestors of John Doe")
print(gramps_data)
via Stdio
import subprocess
import json
def query_ollama(prompt):
result = subprocess.run(
["ollama", "run", "mistral", prompt],
capture_output=True,
text=True
)
return result.stdout
# Exemple d'utilisation
gramps_data = query_gramps_mcp("Find all ancestors of John Doe")
enriched_prompt = f"""
Using the following Gramps data:
{gramps_data}
Answer this question: Who are the parents of John Doe?
"""
llm_response = query_ollama(enriched_prompt)
print(llm_response)
Ollama
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "mistralai/Mistral-7B-Instruct-v0.2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def query_local_llm(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Exemple
gramps_data = query_gramps_mcp("Find all ancestors of John Doe")
enriched_prompt = f"""
Using the following Gramps data:
{gramps_data}
Answer this question: Who are the parents of John Doe?
"""
llm_response = query_local_llm(enriched_prompt)
print(llm_response)
transformers
import requests
import subprocess
import json
def query_gramps_mcp(prompt):
url = "http://localhost:8000/query"
headers = {"Content-Type": "application/json"}
data = {"prompt": prompt}
response = requests.post(url, headers=headers, json=data)
return response.json()
def query_ollama(prompt):
result = subprocess.run(
["ollama", "run", "mistral", prompt],
capture_output=True,
text=True
)
return result.stdout
# 1. Interroger gramps-mcp
gramps_data = query_gramps_mcp("Find all ancestors of John Doe")
# 2. Enrichir la requête pour le LLM
enriched_prompt = f"""
Using the following Gramps data:
{gramps_data}
Answer this question: Who are the parents of John Doe?
"""
# 3. Envoyer au LLM local
llm_response = query_ollama(enriched_prompt)
print(llm_response)
http + Ollama
etc.
""" Ce code est inspiré des exemples et documentations suivants :
- gramps-mcp : https://github.com/cabout-me/gramps-mcp (Licence : [à vérifier])
- Mistral AI MCP : https://docs.mistral.ai/agents/mcp/ (Licence : MIT/Apache 2.0)
- Ollama : https://ollama.ai/ (Licence : MIT)
- Hugging Face Transformers : https://huggingface.co/docs/transformers/index (Licence : Apache 2.0)
For testing: A recent PC with 16 GB of RAM and a mid-range GPU (such as an RTX 3060) is sufficient for Mistral 7B.
For regular use: 32 GB of RAM and a GPU like the RTX 4090 are ideal.
For production or large models: A workstation with a professional GPU (A100/H100) and 64 GB+ of RAM is required.
Example setup for gramps-mcp + Mistral 7B
Hardware:
Software:
Expected Performance:
Adapté et combiné pour une utilisation locale avec des LLM et gramps-mcp. """