oMLX ejecuta LLM localmente en Apple Silicon pero no tiene búsqueda web integrada. Agregar un servidor MCP de búsqueda brinda a los modelos locales acceso web en vivo para obtener respuestas fundamentadas. Este tutorial configura la conexión MCP, crea una herramienta de búsqueda y la prueba con consultas oMLX. Cada búsqueda cuesta $0,005.
Requisitos previos
- oMLX instalado en macOS
- Python 3.8+
- Una clave API de Scavio de scavio.dev
- Mac de silicona de Apple
Guia paso a paso
Paso 1: Crear servidor de búsqueda MCP para oMLX
Cree un servidor MCP liviano al que oMLX pueda conectarse para realizar búsquedas web.
import os, requests, json
from http.server import HTTPServer, BaseHTTPRequestHandler
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
def web_search(query, num_results=5):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us', 'num_results': num_results}).json()
return [{'title': r.get('title', ''), 'link': r.get('link', ''),
'snippet': r.get('snippet', '')} for r in data.get('organic_results', [])[:num_results]]
# MCP tool definition for oMLX
mcp_tool = {
'name': 'web_search',
'description': 'Search the web for current information. Use for any question about recent events, current data, or facts you are not certain about.',
'input_schema': {
'type': 'object',
'properties': {
'query': {'type': 'string', 'description': 'The search query'}
},
'required': ['query']
}
}
# Test the tool
results = web_search('latest macOS release 2026')
for r in results:
print(f'{r["title"]}: {r["link"]}')
print(f'\nTool definition ready for oMLX')
print(json.dumps(mcp_tool, indent=2))Paso 2: Configura oMLX para usar la herramienta de búsqueda
Agregue la configuración del servidor MCP a la configuración de oMLX.
# oMLX MCP configuration file: ~/.omlx/mcp.json
omlx_config = {
'mcpServers': {
'scavio-search': {
'command': 'npx',
'args': ['-y', '@anthropic-ai/mcp-server-scavio'],
'env': {
'SCAVIO_API_KEY': os.environ.get('SCAVIO_API_KEY', 'your-key-here')
}
}
}
}
# Alternative: direct HTTP MCP server
# If oMLX supports HTTP MCP servers:
omlx_http_config = {
'mcpServers': {
'web-search': {
'url': 'http://localhost:3100/mcp',
'tools': [mcp_tool]
}
}
}
config_path = os.path.expanduser('~/.omlx/mcp.json')
print(f'Save this config to: {config_path}')
print(json.dumps(omlx_config, indent=2))
print(f'\nThen restart oMLX to pick up the new MCP server')Paso 3: Pruebe la conexión a tierra de búsqueda con oMLX
Verifique que los modelos oMLX utilicen la herramienta de búsqueda para obtener información actual.
def test_grounded_query(query):
"""Simulate what oMLX does: search then format context."""
results = web_search(query)
context = '\n'.join([f'[{i+1}] {r["title"]}: {r["snippet"]}' for i, r in enumerate(results)])
print(f'Query: {query}')
print(f'Search returned {len(results)} results')
print(f'\nContext for LLM:')
print(context[:500])
print(f'\nThe local LLM now has current data to answer accurately.')
print(f'Cost: $0.005')
test_queries = [
'what is the latest version of python',
'best local LLM for coding 2026',
'apple silicon m5 benchmarks',
]
for q in test_queries:
test_grounded_query(q)
print()Ejemplo en Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def omlx_search(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us', 'num_results': 5}).json()
for r in data.get('organic_results', [])[:3]:
print(f'{r["title"]}: {r.get("snippet", "")[:60]}')
omlx_search('latest macOS release 2026')
print('Cost: $0.005')Ejemplo en JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
async function omlxSearch(query) {
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query, country_code: 'us', num_results: 5 })
}).then(r => r.json());
(data.organic_results || []).slice(0, 3).forEach(r => console.log(`${r.title}`));
}
await omlxSearch('latest macOS release 2026');Salida esperada
Query: what is the latest version of python
Search returned 5 results
Context for LLM:
[1] Python Release Python 3.13.2: Python 3.13.2 is the latest stable release...
[2] Download Python: The current production versions are Python 3.13.2 and...
[3] What's New In Python 3.13: This article explains the new features in...
The local LLM now has current data to answer accurately.
Cost: $0.005