#!/usr/bin/env python3
"""
Direct update of Notion Tech Stack database using Notion API
This replaces the previous approach - directly updates the database
"""
import subprocess
import json
import sys
import requests
def get_notion_token():
"""Get Notion API token from 1Password"""
result = subprocess.run(
['op', 'item', 'get', 'Alice Notion API', '--vault', 'AI', '--fields', 'credential', '--reveal'],
capture_output=True,
text=True
)
if result.returncode != 0:
print(f"Error getting Notion token: {result.stderr}", file=sys.stderr)
sys.exit(1)
return result.stdout.strip()
def create_page_in_database(notion_token, database_id):
"""Create a new page in the Tech Stack database"""
url = "https://api.notion.com/v1/pages"
headers = {
"Authorization": f"Bearer {notion_token}",
"Notion-Version": "2022-06-28",
"Content-Type": "application/json"
}
data = {
"parent": {"database_id": database_id},
"properties": {
"Name": {
"title": [
{
"text": {
"content": "xai-grok-mcp-server"
}
}
]
},
"Subcription Status": {
"select": {
"name": "Active"
}
},
"Category": {
"select": {
"name": "AI"
}
},
"Tech": {
"multi_select": [
{"name": "TypeScript"},
{"name": "Node.js"},
{"name": "MCP"},
{"name": "x.ai"},
{"name": "Grok"}
]
},
"Website": {
"url": "https://github.com/darkangelpraha/xai-grok-mcp-server"
},
"Notes": {
"rich_text": [
{
"text": {
"content": "MCP server for x.ai Grok API - chat completions and AI interactions. Published on npm (mcp-server-xai-grok@1.0.0), GitHub, Docker Hub, and GHCR. Local: /Users/premiumgastro/Projects/xai-grok-mcp-server/. API Key: 1Password (op://AI/API Credentials | Grok Business/API KEY). Integrated into Claude Desktop."
}
}
]
}
},
"children": [
{
"object": "block",
"type": "heading_2",
"heading_2": {
"rich_text": [{"type": "text", "text": {"content": "Links"}}]
}
},
{
"object": "block",
"type": "bulleted_list_item",
"bulleted_list_item": {
"rich_text": [
{"type": "text", "text": {"content": "GitHub: "}, "annotations": {"bold": True}},
{"type": "text", "text": {"content": "https://github.com/darkangelpraha/xai-grok-mcp-server", "link": {"url": "https://github.com/darkangelpraha/xai-grok-mcp-server"}}}
]
}
},
{
"object": "block",
"type": "bulleted_list_item",
"bulleted_list_item": {
"rich_text": [
{"type": "text", "text": {"content": "npm: "}, "annotations": {"bold": True}},
{"type": "text", "text": {"content": "https://www.npmjs.com/package/mcp-server-xai-grok", "link": {"url": "https://www.npmjs.com/package/mcp-server-xai-grok"}}}
]
}
},
{
"object": "block",
"type": "bulleted_list_item",
"bulleted_list_item": {
"rich_text": [
{"type": "text", "text": {"content": "Docker Hub: "}, "annotations": {"bold": True}},
{"type": "text", "text": {"content": "premiumgastro/mcp-server-xai-grok"}}
]
}
}
]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
result = response.json()
print(f"✅ Successfully created page: {result.get('url', 'N/A')}")
return result
else:
print(f"❌ Error: {response.status_code}")
print(f"Response: {response.text}", file=sys.stderr)
return None
if __name__ == "__main__":
database_id = "169d8b84-5bc9-80f5-a50b-e53787fc438e" # Tech Stack and Subcriptions
print("Getting Notion API token...")
notion_token = get_notion_token()
print("Creating page in Tech Stack database...")
result = create_page_in_database(notion_token, database_id)
sys.exit(0 if result else 1)