mcpField
W
Web Algebra

Web Algebra

本地服务
github.com/AtomGraph数据库46今天更新

关于 Web Algebra

Web Algebra 将自然语言指令转换为用于加载、查询和写入 RDF Linked Data 的 JSON DSL 操作,也可独立执行这些操作。它面向构建语义数据工作流的 Agent,支持把多个操作组合为一次执行,并包含 LinkedDataHub 专用操作。

主要功能

  1. 01RDF Linked Data 读写操作
  2. 02SPARQL 查询与构造
  3. 03嵌套 JSON DSL 操作组合
  4. 04控制流、变量与 URI 操作
  5. 05LinkedDataHub 内容操作

适用场景

  1. 01组合多个 RDF 数据处理步骤
  2. 02查询或更新 Linked Data
  3. 03生成 LinkedDataHub 资源与视图
  4. 04通过自然语言生成 RDF 操作计划

MCP 相关

Web Algebra 将操作作为工具提供给 MCP 客户端,供 Agent 交互使用。多个操作也可先组合成 JSON DSL,再由执行引擎原子执行。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"atomgraph-web-algebra": {
"command": "uvx",
"args": [
"web-algebra"
],
"env": {
"CERT_PEM_PATH": "<CERT_PEM_PATH>",
"CERT_PASSWORD": "<CERT_PASSWORD>",
"OPENAI_API_KEY": "<OPENAI_API_KEY>"
}
}
}
}
启动命令uvx web-algebra
需要配置的环境变量
CERT_PEM_PATHPath to the LinkedDataHub client certificate (PEM), for authenticated requests
CERT_PASSWORD密钥Password of the client certificate
OPENAI_API_KEY密钥OpenAI API key, used by SPARQLString to write queries

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypiweb-algebra2.0.1

工具

33

收录的工具列表 · 更新于 1 周前

参数类型必填说明
urlstring是要获取 RDF 数据的 URL。必须是指向 RDF 内容的有效 URL。

README 原文English

来自项目 README

README 暂无中文译文,以下为英文原文;中文介绍见上方。

Web-Algebra

Web-Algebra - Listed on Claude AI Directory

A composable RDF operations system that translates natural language instructions into JSON-formatted domain-specific language operations for loading, querying, and writing RDF Linked Data.

Overview

This system implements generic operations for RDF Linked Data and SPARQL management, as well as some LinkedDataHub-specific operations. Operations can be consumed in two ways:

  1. Executable JSON format: Operations are composed into JSON structures and executed by the provided execution engine
  2. Model Context Protocol (MCP): Operations are exposed as tools for AI agents to use interactively

Instead of agents executing semantic workflows step-by-step through individual MCP tool calls, Web-Algebra enables agents to compile entire workflows into optimized JSON "bytecode" that executes atomically - enabling complex multi-operation compositions.

Demo

Web-Algebra in action: an AI agent builds Linked Data pages over MCP

See WebAlgebra in action - translating natural language into RDF operations.

Architecture

The system is built around the Operation abstract base class that provides:

  • Registry System: Auto-discovery of operations from src/web_algebra/operations/
  • JSON DSL: Operations use @op key with args for parameters, supporting nested operation calls
  • RDFLib Type System: Uses URIRef, Literal, Graph, and Result types internally for proper RDF handling
  • Execution Engine: Both standalone execution and MCP server integration
  • Context System: ForEach operations set row context for inner operations to access via Value
  • URI Resolution: Proper semantic URI construction with ResolveURI operation
Key Components
Operations

The operations cover read-write Linked Data, SPARQL queries, URI manipulation, and LinkedDataHub-specific resource creation. Non-exhaustive list:

  • Linked Data
    • GET
    • PATCH
    • POST
    • PUT
  • SPARQL
    • CONSTRUCT
    • DESCRIBE
    • SELECT
    • Substitute
    • Values
    • SPARQLString
  • Schema
    • ExtractClasses
    • ExtractDatatypeProperties
    • ExtractObjectProperties
    • ExtractOntology
  • URI & String Operations
    • ResolveURI
    • EncodeForURI
    • Concat
    • Replace
    • Str
    • StrUUID
    • URI
  • Date/Time
    • Now
  • Control Flow & Variables
    • Value
    • Variable
    • ForEach
    • Iterate
    • Filter
    • Bindings
    • Current
    • Position
    • Last
    • Merge
  • LinkedDataHub-specific
    • ldh-CreateContainer
    • ldh-CreateItem
    • ldh-List
    • ldh-AddFile
    • ldh-AddGenericService
    • ldh-AddResultSetChart
    • ldh-AddSelect
    • ldh-AddConstruct
    • ldh-AddView
    • ldh-AddObjectBlock
    • ldh-AddXHTMLBlock
    • ldh-RemoveBlock
    • ldh-GeneratePortal
    • ldh-GenerateClassContainers
    • ldh-GenerateOntologyViews

Usage

Pre-requisites
  1. Install uv
  2. uv venv
    uv sync
    
Standalone
Natural language instruction
uv run python src/web_algebra/main.py

Then enter instruction, for example:

Select random 10 UK cities from DBpedia

See the instructions of the examples.

Currently requires OpenAI API access. OPENAI_API_KEY env value has to be set.

Execute JSON
uv run web-algebra --from-json ./examples/city-profiles/plan.json

See the examples: each has the instruction it answers, its plan, the result of a run, and checks.

With LinkedDataHub
  1. Run LinkedDataHub v6
  2. Give web-algebra your LDH's owner certificate and its password in the CERT_PEM_PATH and CERT_PASSWORD environment variables (or the --cert_pem_path and --cert_password options, which override them). For example:
export CERT_PEM_PATH=../LinkedDataHub/ssl/owner/cert.pem
export CERT_PASSWORD="$(cat ../LinkedDataHub/secrets/owner_cert_password.txt)"
uv run web-algebra --from-json ./examples/northwind-category-catalogue/plan.json

Here and throughout this guide, the client certificate and its password are only required for authentication with LinkedDataHub. You don't need them if you're not using LinkedDataHub with Web Algebra.

As MCP server
Install

Requires uv. Add this to your MCP client configuration (e.g. claude_desktop_config.json):

{
    "mcpServers": {
        "web-algebra": {
            "command": "uvx",
            "args": ["--from", "web-algebra", "web-algebra-mcp"],
            "env": {
                "CERT_PEM_PATH": "/path/to/LinkedDataHub/ssl/owner/cert.pem",
                "CERT_PASSWORD": "********"
            }
        }
    }
}

or with Claude Code:

claude mcp add web-algebra -e CERT_PEM_PATH=/path/to/LinkedDataHub/ssl/owner/cert.pem -e CERT_PASSWORD=******** -- uvx --from web-algebra web-algebra-mcp

uvx web-algebra mcp runs the same server.

Environment variables:

NameRequiredDescription
CERT_PEM_PATHNoPath to the LinkedDataHub owner certificate (PEM). Only needed for LinkedDataHub operations.
CERT_PASSWORDNoPassword for the certificate above.
OPENAI_API_KEYNoOpenAI API key. Only needed for the SPARQLString tool, which asks a model to write the query.
stdio transport
uv run web-algebra-mcp
Streamable HTTP transport
uv run uvicorn web_algebra.server:app --reload

with CERT_PEM_PATH and CERT_PASSWORD set, as above, for LinkedDataHub.

MCP Inspector config

You can the inspector like this:

npx @modelcontextprotocol/inspector

and then open on the URL printed in its console output, for example:

http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=b31e4b3d852b5a2445f45032c484e54e319bf16359585858cf88fe9a90816744

The MCP_PROXY_AUTH_TOKEN is required. If the link does not appear, you need to copy the session token from the console and paste it into inspector's Proxy Session Token config.

Web Algebra's settings:

Transport Type
Streamable HTTP
URL
http://127.0.0.1:8000/mcp
Claude Desktop tool config from a local checkout

To run the MCP server from a local checkout instead of the published package, add a Web Algebra entry (that uses stdio transport) to the mcpServer configuration your claude_desktop_config.json file:

{
    "mcpServers": {
        "Web Algebra": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/Web-Algebra",
                "run",
                "web-algebra-mcp"
            ],
            "env": {
                "CERT_PEM_PATH": "/path/to/LinkedDataHub/ssl/owner/cert.pem",
                "CERT_PASSWORD": "********"
            }
        }
    }
}

Leave the command as it is. Those uv run --with arguments are important, otherwise 3rd party packages cannot be found.

On my Mac, the path to uv has to be absolute, otherwise it doesn't work in Claude Desktop 🤷‍♂️.

CERT_PEM_PATH and CERT_PASSWORD env values are optional.

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。