# Setup Guide for MCP Datastore Server
## Prerequisites
1. **Google Cloud Project** with Firestore in Datastore mode enabled
2. **Service Account** with appropriate permissions:
- Cloud Datastore User (or Owner)
3. **Service Account Key** JSON file downloaded
## Step 1: Install Dependencies
```powershell
npm install
```
This will automatically build the TypeScript code.
## Step 2: Configure Google Cloud Credentials
### Option A: Environment Variables (Recommended for development)
Create a `.env` file in the project root:
```env
GOOGLE_APPLICATION_CREDENTIALS=C:\path\to\service-account-key.json
GOOGLE_CLOUD_PROJECT=your-project-id
```
### Option B: System Environment Variables
Set these in your system:
```powershell
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\service-account-key.json"
$env:GOOGLE_CLOUD_PROJECT="your-project-id"
```
## Step 3: Test the Server Locally
```powershell
npm start
```
The server will start and listen for MCP commands via stdio.
## Step 4: Configure Claude Desktop
### Windows Configuration
1. Open the Claude Desktop config file at:
```
%APPDATA%\Claude\claude_desktop_config.json
```
2. Add the MCP server configuration:
```json
{
"mcpServers": {
"datastore": {
"command": "node",
"args": [
"d:\\projects\\mcp-datastore\\build\\index.js"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "C:\\path\\to\\service-account-key.json",
"GOOGLE_CLOUD_PROJECT": "your-project-id"
}
}
}
}
```
**Important Notes:**
- Use double backslashes (`\\`) in paths for Windows
- Use absolute paths for the node script
- Replace `your-project-id` with your actual Google Cloud project ID
- Replace the credentials path with your actual service account key file location
### macOS Configuration
1. Open the Claude Desktop config file at:
```
~/Library/Application Support/Claude/claude_desktop_config.json
```
2. Add the MCP server configuration:
```json
{
"mcpServers": {
"datastore": {
"command": "node",
"args": [
"/absolute/path/to/mcp-datastore/build/index.js"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account-key.json",
"GOOGLE_CLOUD_PROJECT": "your-project-id"
}
}
}
}
```
## Step 5: Configure VS Code (Optional)
If you're using VS Code with MCP support, create or update `.vscode/settings.json`:
```json
{
"mcp.servers": {
"datastore": {
"command": "node",
"args": [
"${workspaceFolder}\\build\\index.js"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "${workspaceFolder}\\service-account-key.json",
"GOOGLE_CLOUD_PROJECT": "your-project-id"
}
}
}
}
```
## Step 6: Restart Claude Desktop
After updating the configuration, restart Claude Desktop completely:
1. Quit Claude Desktop
2. Relaunch it
3. The MCP server should now be available
## Verification
In Claude Desktop, you should now be able to use commands like:
- "List entities of kind 'User' from Datastore"
- "Get entity with kind 'User' and ID '12345'"
- "Insert a new User entity with name 'John Doe'"
## Troubleshooting
### Server not connecting
1. Check that the paths in your config are correct (use absolute paths)
2. Verify your service account has the necessary permissions
3. Check Claude Desktop logs (usually in AppData on Windows)
### Authentication errors
1. Verify `GOOGLE_APPLICATION_CREDENTIALS` points to a valid JSON key file
2. Ensure the service account has Cloud Datastore User role
3. Check that `GOOGLE_CLOUD_PROJECT` matches your actual project ID
### Build errors
```powershell
# Clean rebuild
Remove-Item -Recurse -Force build
npm run build
```
### Testing without Claude Desktop
You can test the server manually:
```powershell
# Set environment variables
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\key.json"
$env:GOOGLE_CLOUD_PROJECT="your-project-id"
# Start the server
npm start
```
Then send MCP protocol messages via stdin to test functionality.
## Security Best Practices
1. **Never commit** your service account key to version control
2. Use `.gitignore` to exclude `*.key.json` files
3. Use environment-specific credentials (dev, staging, prod)
4. Rotate service account keys regularly
5. Follow the principle of least privilege for service account permissions
## Additional Resources
- [Google Cloud Datastore Documentation](https://cloud.google.com/datastore/docs)
- [Model Context Protocol Specification](https://modelcontextprotocol.io)
- [Claude Desktop Documentation](https://claude.ai/docs)