diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index de572d0..2607e76 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,3 +31,9 @@ jobs: mcp_server: "cdb8573a-fd90-461a-a869-a6166a542592" token: ${{secrets.ORGANIZATION_DEMO_BUMP_TOKEN}} file: workflows/weather.yml + - name: Deploy Wikimedia workflow document + uses: bump-sh/github-action@v1 + with: + mcp_server: "d1a6ad45-ca49-4c20-9440-f273988abba5" + token: ${{secrets.ORGANIZATION_DEMO_BUMP_TOKEN}} + file: workflows/wikimedia.json diff --git a/workflows/README.md b/workflows/README.md index b7a14c6..54640bb 100644 --- a/workflows/README.md +++ b/workflows/README.md @@ -4,5 +4,6 @@ This directory holds [Flower](https://github.com/bump-sh/flower-spec) example Wo The files are automatically deployed to Bump.sh, You can test them live at: -- [Weather server](https://github.com/bump-sh/examples/blob/main/workflows/weather.yml): https://run.bump.sh/demo/weather/mcp +- [Weather server (flower definition)](https://github.com/bump-sh/examples/blob/main/workflows/weather.yml): https://run.bump.sh/demo/weather/mcp +- [Wikimedia server (arazzo definition)](https://github.com/bump-sh/examples/blob/main/workflows/wikimedia.json): https://run.bump.sh/demo/wikimedia/mcp diff --git a/workflows/wikimedia.json b/workflows/wikimedia.json new file mode 100644 index 0000000..7eeac11 --- /dev/null +++ b/workflows/wikimedia.json @@ -0,0 +1,111 @@ +{ + "arazzo": "1.0.1", + "info": { + "title": "Wikimedia Math API", + "version": "1.0.0", + "description": "Based on Jentic automatically generated Arazzo specification but adapted by humans to make it actually work" + }, + "sourceDescriptions": [ + { + "name": "openapi_source", + "url": "./wikimedia/openapi.json", + "type": "openapi" + } + ], + "workflows": [ + { + "workflowId": "render-mathematical-formula", + "summary": "Checks a TeX formula for validity and correctness, then renders it into a specified visual format (SVG, MML, or PNG). This is useful for displaying mathematical notation dynamically.", + "description": "Checks a TeX formula for validity and correctness, then renders it into a specified visual format (SVG, MML, or PNG). This is useful for displaying mathematical notation dynamically.", + "inputs": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["tex", "inline-tex", "chem"], + "default": "tex" + }, + "formula": { + "type": "string" + }, + "format": { + "type": "string", + "enum": ["svg", "mml", "png"], + "default": "svg" + }, + "email": { + "type": "string", + "description": "Wikimedia API usage policy asks for an email or url to prevent abuse. Please use this fairly. https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy" + } + } + }, + "steps": [ + { + "stepId": "check-formula", + "description": "Submits a TeX or inline-TeX formula for validation and normalization. Returns formula information and a hash identifier in the 'x-resource-location' header for rendering.", + "operationPath": "openapi_source#/paths/~1media~1math~1check~1{type}/post", + "parameters": [ + { + "name": "type", + "in": "path", + "value": "$inputs.type" + }, + { + "name": "User-Agent", + "in": "header", + "value": "Arazzo Workflow (From:$inputs.email)" + } + ], + "requestBody": { + "contentType": "multipart/form-data", + "payload": { + "q": "$inputs.formula" + } + }, + "successCriteria": [ + { + "condition": "$statusCode == 200" + }, + { + "condition": "$response.body#/success == true" + } + ], + "outputs": { + "formula_info": "$response.body", + "formula_hash": "$response.header.x-resource-location" + } + }, + { + "stepId": "render-formula", + "description": "Retrieves the rendered representation (SVG, MML, or PNG) of a previously checked formula using its hash.", + "operationPath": "openapi_source#/paths/~1media~1math~1render~1{format}~1{hash}/get", + "parameters": [ + { + "name": "format", + "in": "path", + "value": "$inputs.format" + }, + { + "name": "hash", + "in": "path", + "value": "$steps.check-formula.outputs.formula_hash" + } + ], + "successCriteria": [ + { + "condition": "$statusCode == 200" + } + ], + "outputs": { + "rendered_formula": "$response.body" + } + } + ], + "outputs": { + "formula_info": "$steps.check-formula.outputs.formula_info", + "formula_hash": "$steps.check-formula.outputs.formula_hash", + "rendered_formula": "$steps.render-formula.outputs.rendered_formula" + } + } + ] +} diff --git a/workflows/wikimedia/openapi.json b/workflows/wikimedia/openapi.json new file mode 100644 index 0000000..ef1cc89 --- /dev/null +++ b/workflows/wikimedia/openapi.json @@ -0,0 +1,483 @@ +{ + "openapi": "3.0.1", + "info": { + "version": "1.0.0", + "title": "Wikimedia REST API", + "description": "This API provides cacheable and straightforward access to Wikimedia content and data, in machine-readable formats.\n### Global Rules\n- Limit your clients to no more than 200 requests/s to this API.\n Each API endpoint's documentation may detail more specific usage limits.\n- Set a unique `User-Agent` or `Api-User-Agent` header that\n allows us to contact you quickly. Email addresses or URLs\n of contact pages work well.\n\nBy using this API, you agree to Wikimedia's [Terms of Use](https://wikimediafoundation.org/wiki/Terms_of_Use) and [Privacy Policy](https://wikimediafoundation.org/wiki/Privacy_policy). Unless otherwise specified in the endpoint documentation below, content accessed via this API is licensed under the [CC-BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/) and [GFDL](https://www.gnu.org/copyleft/fdl.html) licenses, and you irrevocably agree to release modifications or additions made through this API under these licenses. See https://www.mediawiki.org/wiki/REST_API for background and details.\n ### Endpoint documentation\nPlease consult each endpoint's documentation for details on:\n- Licensing information for the specific type of content\n and data served via the endpoint.\n- Stability markers to inform you about development status and\n change policy, according to\n [our API version policy](https://www.mediawiki.org/wiki/API_versioning).\n - Endpoint specific usage limits.\n### Metrics endpoints\nFor documentation for `/metrics` endpoints, including pageviews, unique devices, edited pages, editors, edits, registered users, bytes difference, and mediarequests data, see the [Wikimedia Analytics API documentation](https://doc.wikimedia.org/analytics-api).\n", + "termsOfService": "https://wikimediafoundation.org/wiki/Terms_of_Use", + "contact": { + "name": "the Wikimedia Services team", + "url": "http://mediawiki.org/wiki/REST_API" + }, + "license": { + "name": "Software available under the Apache 2 license", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + }, + "x-jentic-source-url": "https://wikimedia.org/api/rest_v1/?spec" + }, + "servers": [ + { + "url": "https://wikimedia.org/api/rest_v1" + } + ], + "paths": { + "/media/math/check/{type}": { + "post": { + "tags": [ + "Math" + ], + "summary": "Check and normalize a TeX formula.", + "description": "Checks the supplied TeX formula for correctness and returns the\n normalised formula representation as well as information about\nidentifiers. Available types are tex and inline-tex. The response\ncontains the `x-resource-location` header which can be used to retrieve\nthe render of the checked formula in one of the supported rendering\nformats. Just append the value of the header to `/media/math/{format}/`\nand perform a GET request against that URL.\n\n Stability: [stable](https://www.mediawiki.org/wiki/API_versioning#Stable).\n", + "parameters": [ + { + "name": "type", + "in": "path", + "description": "The input type of the given formula; can be tex or inline-tex", + "required": true, + "schema": { + "type": "string", + "enum": [ + "tex", + "inline-tex", + "chem" + ] + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "q" + ], + "properties": { + "q": { + "type": "string", + "description": "The formula to check" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Information about the checked formula", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "400": { + "description": "Invalid type", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + } + }, + "x-monitor": true, + "x-amples": [ + { + "title": "Mathoid - check test formula", + "request": { + "params": { + "domain": "wikimedia.org", + "type": "tex" + }, + "body": { + "q": "E=mc^{2}" + } + }, + "response": { + "status": 200, + "headers": { + "content-type": "/^application\\/json/", + "x-resource-location": "/.+/", + "cache-control": "no-cache" + }, + "body": { + "success": true, + "checked": "/.+/" + } + } + } + ] + } + }, + "/media/math/formula/{hash}": { + "get": { + "tags": [ + "Math" + ], + "summary": "Get a previously-stored formula", + "description": "Returns the previously-stored formula via `/media/math/check/{type}` for\nthe given hash.\n\nStability: [stable](https://www.mediawiki.org/wiki/API_versioning#Stable).\n", + "parameters": [ + { + "name": "hash", + "in": "path", + "description": "The hash string of the previous POST data", + "required": true, + "schema": { + "minLength": 1, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Information about the checked formula", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Data for the given hash cannot be found", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + } + }, + "x-monitor": false + } + }, + "/media/math/render/{format}/{hash}": { + "get": { + "tags": [ + "Math" + ], + "summary": "Get rendered formula in the given format.", + "description": "Given a request hash, renders a TeX formula into its mathematic\n representation in the given format. When a request is issued to the\n`/media/math/check/{format}` POST endpoint, the response contains the\n`x-resource-location` header denoting the hash ID of the POST data. Once\nobtained, this endpoint has to be used to obtain the actual render.\n\nStability: [stable](https://www.mediawiki.org/wiki/API_versioning#Stable).\n", + "parameters": [ + { + "name": "format", + "in": "path", + "description": "The output format; can be svg or mml", + "required": true, + "schema": { + "type": "string", + "enum": [ + "svg", + "mml", + "png" + ] + } + }, + { + "name": "hash", + "in": "path", + "description": "The hash string of the previous POST data", + "required": true, + "schema": { + "minLength": 1, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The rendered formula", + "content": { + "image/svg+xml": { + "schema": { + "type": "string" + } + }, + "application/mathml+xml": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Unknown format or hash ID", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/problem" + } + } + } + } + }, + "x-monitor": false + } + } + }, + "components": { + "schemas": { + "problem": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "title": { + "type": "string" + }, + "detail": { + "type": "string" + }, + "instance": { + "type": "string" + } + } + }, + "originalimage": { + "type": "object", + "properties": { + "source": { + "type": "string", + "description": "Original image URI" + }, + "width": { + "type": "integer", + "description": "Original image width" + }, + "height": { + "type": "integer", + "description": "Original image height" + } + }, + "required": [ + "height", + "source", + "width" + ] + }, + "thumbnail": { + "type": "object", + "properties": { + "source": { + "type": "string", + "description": "Thumbnail image URI" + }, + "width": { + "type": "integer", + "description": "Thumbnail width" + }, + "height": { + "type": "integer", + "description": "Thumnail height" + } + }, + "required": [ + "height", + "source", + "width" + ] + }, + "titles_set": { + "type": "object", + "description": "a good example of the differences can be seen in https://en.wikipedia.org/api/rest_v1/page/summary/IOS_13", + "properties": { + "canonical": { + "type": "string", + "description": "the DB key (non-prefixed), e.g. may have _ instead of spaces, best for making request URIs, still requires Percent-encoding" + }, + "normalized": { + "type": "string", + "description": "the normalized title (https://www.mediawiki.org/wiki/API:Query#Example_2:_Title_normalization), e.g. may have spaces instead of _" + }, + "display": { + "type": "string", + "description": "the title as it should be displayed to the user" + } + }, + "required": [ + "canonical", + "normalized", + "display" + ] + }, + "summary": { + "type": "object", + "properties": { + "titles": { + "$ref": "#/components/schemas/titles_set" + }, + "title": { + "deprecated": true, + "type": "string", + "description": "The page title.\nDeprecated: Use `titles.normalized` instead.\n" + }, + "displaytitle": { + "deprecated": true, + "type": "string", + "description": "The page title how it should be shown to the user.\nDeprecated: Use `titles.display` instead.\n" + }, + "pageid": { + "type": "integer", + "description": "The page ID" + }, + "extract": { + "type": "string", + "description": "First several sentences of an article in plain text" + }, + "extract_html": { + "type": "string", + "description": "First several sentences of an article in simple HTML format" + }, + "thumbnail": { + "$ref": "#/components/schemas/thumbnail" + }, + "originalimage": { + "$ref": "#/components/schemas/originalimage" + }, + "lang": { + "type": "string", + "description": "The page language code", + "example": "en" + }, + "dir": { + "type": "string", + "description": "The page language direction code", + "example": "ltr" + }, + "timestamp": { + "type": "string", + "description": "The time when the page was last edited in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format", + "example": {} + }, + "description": { + "type": "string", + "description": "Wikidata description for the page", + "example": "American poet" + }, + "coordinates": { + "type": "object", + "description": "The coordinates of the item", + "properties": { + "lat": { + "type": "number", + "description": "The latitude" + }, + "lon": { + "type": "number", + "description": "The longitude" + } + }, + "required": [ + "lat", + "lon" + ] + } + }, + "required": [ + "dir", + "extract", + "lang", + "titles" + ] + }, + "cx_mt": { + "type": "object", + "properties": { + "contents": { + "type": "string", + "description": "the translated content" + } + } + }, + "cx_dict": { + "type": "object", + "properties": { + "source": { + "type": "string", + "description": "the original word to look up" + }, + "translations": { + "type": "array", + "description": "the translations found", + "items": { + "type": "object", + "properties": { + "phrase": { + "type": "string", + "description": "the translated phrase" + }, + "info": { + "type": "string", + "description": "extra information about the phrase" + }, + "sources": { + "type": "string", + "description": "the source dictionary used for the translation" + } + } + } + } + } + } + } + }, + "tags": [ + { + "name": "Math", + "description": "formula rendering" + } + ], + "securityDefinitions": { + "mediawiki_auth": { + "description": "Checks permissions using MW api", + "type": "apiKey", + "in": "header", + "name": "cookie", + "x-internal-request-whitelist": [ + "/http:\\/\\/[a-zA-Z0-9\\.]+\\/w\\/api\\.php/" + ] + } + }, + "x-host-basePath": "/api/rest_v1", + "x-default-params": {} +} \ No newline at end of file