MPC-PoC-2-ResourceProvider-GoogleSheets

MPC-PoC-2-ResourceProvider-GoogleSheets

MCP server that exposes Google Sheets as read-only resources, providing static and templated URI access to sheet data as CSV.

Category
Visit Server

README

MPC-PoC-2-ResourceProvider-GoogleSheets

MCP server que expone Google Sheets como Resources (lectura), no como Tools. Segunda PoC de la serie "Aprender MCP en profundidad".

Qué expone

  • Resource estático — sheet://main/data: contenido completo de la hoja principal (MAIN_SHEET_NAME, rango MAIN_SHEET_RANGE).
  • Resource template — sheet://{sheet_name}/{cell_range}: lee cualquier hoja/rango dinámicamente. Ej: sheet://Ventas/A1:D50. Si el nombre de la hoja tiene espacios, codificarlo en la URI (ej. sheet://Hoja%201/A1:C10).

Ambos devuelven el contenido como CSV (mimeType: text/csv).

Setup

1. Google Cloud

  1. Crear (o reusar) un proyecto en Google Cloud Console.
  2. Habilitar la Google Sheets API para ese proyecto (APIs & Services → Enable APIs → "Google Sheets API").
  3. Crear un Service Account (IAM & Admin → Service Accounts → Create Service Account).
  4. Generar una key JSON para ese service account (pestaña "Keys" → Add Key → JSON) y descargarla.
  5. Compartir la Google Sheet con el email del service account (algo como nombre@proyecto.iam.gserviceaccount.com), con permiso de lector. Este paso se olvida siempre y produce un error 403.

2. Proyecto local

uv sync
cp .env.example .env

Completar .env:

SPREADSHEET_ID=<el ID de la spreadsheet, va en la URL entre /d/ y /edit>
GOOGLE_APPLICATION_CREDENTIALS=credentials.json
MAIN_SHEET_NAME=Sheet1
MAIN_SHEET_RANGE=A1:Z1000

Guardar la key JSON del service account como credentials.json en la raíz del proyecto (o ajustar la ruta en GOOGLE_APPLICATION_CREDENTIALS). Nunca commitear este archivo — ya está en .gitignore.

3. Correr el server

uv run python server.py

El server habla MCP sobre stdio. Para probarlo interactivamente:

uv run mcp dev server.py

Para usarlo desde Claude Desktop, agregar en claude_desktop_config.json:

{
  "mcpServers": {
    "sheets-resources": {
      "command": "uv",
      "args": ["--directory", "/ruta/absoluta/a/este/proyecto", "run", "python", "server.py"]
    }
  }
}

Reiniciar Claude Desktop y verificar que el server aparece con los dos resources listados.

Estructura

server.py           # MCP server: registra los resources
sheets_client.py     # wrapper de la Google Sheets API (auth + read_range)
.env.example         # variables de entorno de referencia
.gitignore           # excluye credentials*.json y .env

Variables de entorno

Variable Requerida Default Descripción
SPREADSHEET_ID Sí — ID de la spreadsheet a exponer
GOOGLE_APPLICATION_CREDENTIALS No credentials.json Ruta a la key JSON del service account
MAIN_SHEET_NAME No Sheet1 Hoja que expone el resource estático
MAIN_SHEET_RANGE No A1:Z1000 Rango que expone el resource estático

Qué aprendí

  • Resources son application-controlled, no model-controlled: a diferencia de un Tool, el LLM no "decide ejecutar" un resource con side effects — el cliente decide qué exponer y cuándo leerlo como contexto. El server solo declara qué existe y cómo leerlo.
  • La URI es el contrato: un resource se identifica por su URI (sheet://main/data), no por un nombre de función. Eso permite que resources estáticos y templated convivan bajo el mismo esquema (sheet://{sheet_name}/{cell_range}), sin necesidad de "argumentos" en el sentido de Tools.
  • Templates son URIs con match, no RPC con parámetros validados por schema: el SDK resuelve {sheet_name} y {cell_range} vía regex sobre la URI (cada segmento sin /), y recién ahí invoca la función — es más parecido a un router HTTP que a la firma de un Tool.
  • Cuándo elegir Resource vs Tool: si la acción es "dame datos para que los uses como contexto" → Resource. Si es "hacé algo (leer con efectos, escribir, calcular, invocar una API con params arbitrarios que decide el modelo)" → Tool. Google Sheets de solo lectura calza perfecto como Resource porque no hay acción que "invocar": es data que el LLM lee, igual que leería un archivo.

alt text

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured