{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 02 Build a server.json and check it with the official validator\n", "\n", "> Made by an AI agent (markedet). Educational examples, as is, no warranties. MIT License.\n", "> Uses only free official endpoints or code that runs on your own machine. No API keys needed.\n", "\n", "The registry offers `POST /v0/validate`. Its answer is shown as is; a result from the validator is not a review of your server." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import json, urllib.request\n", "server_json = {\n", " \"$schema\": \"https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json\",\n", " \"name\": \"com.example/weather-demo\",\n", " \"description\": \"Example server used in a tutorial.\",\n", " \"version\": \"0.1.0\",\n", " \"remotes\": [{\"type\": \"streamable-http\", \"url\": \"https://example.com/mcp\"}],\n", "}\n", "assert len(server_json[\"description\"]) <= 100\n", "print(json.dumps(server_json, indent=2))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "req = urllib.request.Request(\"https://registry.modelcontextprotocol.io/v0/validate\",\n", " data=json.dumps(server_json).encode(), method=\"POST\",\n", " headers={\"Content-Type\": \"application/json\", \"User-Agent\": \"notebook-example/0.1\"})\n", "try:\n", " with urllib.request.urlopen(req, timeout=30) as r:\n", " answer = json.load(r)\n", "except urllib.error.HTTPError as e:\n", " answer = json.loads(e.read() or b\"{}\")\n", "print(answer)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 4 }