Editor como servidor MCP: agentes leem e editam as pilhas por código
tinyblocks-mcp-server (C, sem Python): servidor MCP nas duas eras do protocolo. Moderna (2026-07-28): sem handshake, versão e capacidades em _meta a cada pedido, server/discover, resultType, cabeçalhos MCP-Protocol-Version/Mcp-Method/Mcp-Name conferidos com o corpo (HeaderMismatch, UnsupportedProtocolVersion). Antiga: initialize. HTTP só em 127.0.0.1 (Origin conferido, GET/DELETE 405, sem sessão), sem bloquear (o editor atende a cada quadro), e stdio. test-mcp-server. Ferramentas do editor (tb_editor_mcp.c; http://127.0.0.1:7811/mcp, TINYBLOCKS_MCP_PORT muda a porta, 0 = sem rede): get_editor, list_block_types, list_stacks (scratchblocks + ids dos blocos), get_scratchblocks, add_scratchblocks, replace_stack, move_stack, delete_stack, add_block / move_block (solto, embaixo, num campo ou numa boca; alone = só o bloco) / delete_block / set_inputs, run / stop / get_output, new_tab / select_tab, save_project / open_project e ui_tree / ui_action / ui_type (a interface pela árvore acessível). O editor exporta e importa scratchblocks por pilha (numa aba existente, numa posição), e o modelo de blocos fica na API privada para o servidor. O scratchblocks usa também os rótulos declarados pelas libraries. Duplicar um bloco C de três bocas copiava só duas. O cliente (tinyblocks-mcp) fala as duas eras: sonda com server/discover no stdio, pedido moderno no HTTP, e cai para o initialize com servidores antigos. test-mcp testa contra o servidor antigo de teste e contra o moderno (stdio e HTTP); harness cenário 29 usa as ferramentas do editor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
10a8099c46
commit
2a2d22a64a
19 files changed
+2669
-116
No files matched your search
@@ -46,6 +46,7 @@ SD_DIR := $(LIBDIR)/tinyblocks-sdl2
|
||||
PY_DIR := $(LIBDIR)/tinyblocks-python
|
||||
MC_DIR := $(LIBDIR)/tinyblocks-mcp
|
||||
A11Y_DIR := $(LIBDIR)/tinyblocks-a11y
|
||||
MCPS_DIR := $(LIBDIR)/tinyblocks-mcp-server
|
||||
|
||||
GFX_INC := $(GX_DIR)/include
|
||||
GFX_HDR := $(GFX_INC)/tb_graphics.h
|
||||
@@ -96,13 +97,14 @@ LIBM_A := $(LIBM_DIR)/build/libtinyblocks-libman.a
|
||||
SYN_A := $(SYN_DIR)/build/libtinyblocks-syntax.a
|
||||
SB_A := $(SB_DIR)/build/libtinyblocks-scratchblocks.a
|
||||
A11Y_A := $(A11Y_DIR)/build/libtinyblocks-a11y.a
|
||||
MCPS_A := $(MCPS_DIR)/build/libtinyblocks-mcp-server.a
|
||||
LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
|
||||
$(foreach l,$(CAT_LIBS),-L$(LIBDIR)/tinyblocks-$(l)/build) -L$(BUILD)
|
||||
|
||||
.PHONY: all help debug release static shared example sdl2 clean run python-lib mcp-lib json \
|
||||
editor run-editor run-sdl2 mylib vector customappearance graphics sdl2-backend test-editor \
|
||||
appdir appimage run-appimage icon \
|
||||
test-toml test-plugin test-blueprint test-a11y test-mcp test-base64 test-curves test-meta test-ppm test-bmp test-png test-image test-vg test-svg test-jpg \
|
||||
test-toml test-plugin test-blueprint test-a11y test-mcp test-mcp-server test-base64 test-curves test-meta test-ppm test-bmp test-png test-image test-vg test-svg test-jpg \
|
||||
test-syntax test-os test-value test-vars test-scratchblocks test-input test-stdlib test-regex test-markdown test-opentype \
|
||||
category-libs category-sos libs \
|
||||
lib-events lib-control lib-errors lib-input lib-operators lib-number lib-string lib-variables lib-vector lib-appearance lib-pen lib-fs lib-os \
|
||||
@@ -166,12 +168,15 @@ lib-$(1):
|
||||
endef
|
||||
$(foreach l,$(CAT_LIBS),$(eval $(call CAT_LIB_TARGET,$(l))))
|
||||
|
||||
lib-editor: lib-a11y
|
||||
lib-editor: lib-a11y lib-mcp-server
|
||||
$(MAKE) -C $(ED_DIR)
|
||||
|
||||
lib-a11y:
|
||||
$(MAKE) -C $(A11Y_DIR)
|
||||
|
||||
lib-mcp-server:
|
||||
$(MAKE) -C $(MCPS_DIR)
|
||||
|
||||
lib-toml:
|
||||
$(MAKE) -C $(TOML_DIR)
|
||||
|
||||
@@ -249,7 +254,7 @@ lib-mcp: lib-python
|
||||
|
||||
libs: static lib-events lib-control lib-errors lib-operators lib-variables \
|
||||
lib-appearance lib-pen lib-fs lib-os lib-input lib-number lib-string lib-vector lib-environ lib-graphics lib-sdl2 lib-toml \
|
||||
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman lib-a11y lib-editor
|
||||
lib-json lib-xml lib-csv lib-blueprint lib-base64 lib-curves lib-ppm lib-bmp lib-png lib-image lib-vg lib-svg lib-jpg lib-syntax lib-scratchblocks lib-regex lib-markdown lib-opentype lib-api lib-libman lib-a11y lib-mcp-server lib-editor
|
||||
@echo "Libraries OK: category + graphics + sdl2 + toml + json + xml + csv + blueprint + base64 + curves + ppm + bmp + png + image + vg + svg + jpg + syntax + regex + markdown + opentype + api + libman + a11y + editor"
|
||||
|
||||
category-libs: static $(foreach l,$(CAT_LIBS),lib-$(l)) ## Compila as libraries de categoria (.a/.so)
|
||||
@@ -292,9 +297,9 @@ $(BUILD)/editor: examples/editor/main.c static libs
|
||||
-I$(ED_DIR)/include -I$(GFX_INC) $(CAT_INCS) \
|
||||
-I$(FS_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include \
|
||||
-I$(JSON_DIR)/include -I$(XML_DIR)/include -I$(CSV_DIR)/include -I$(BP_DIR)/include \
|
||||
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(SYN_DIR)/include -I$(A11Y_DIR)/include \
|
||||
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(SYN_DIR)/include -I$(A11Y_DIR)/include -I$(MCPS_DIR)/include \
|
||||
$< -o $@ \
|
||||
-Wl,--start-group $(ED_A) $(A11Y_A) $(GX_A) $(SD_A) $(TOML_A) $(JSON_A) $(XML_A) $(CSV_A) $(BP_A) $(SB_A) $(API_A) $(LIBM_A) $(SYN_A) $(CAT_A) $(LIB_A) -Wl,--end-group \
|
||||
-Wl,--start-group $(ED_A) $(A11Y_A) $(MCPS_A) $(GX_A) $(SD_A) $(TOML_A) $(JSON_A) $(XML_A) $(CSV_A) $(BP_A) $(SB_A) $(API_A) $(LIBM_A) $(SYN_A) $(CAT_A) $(LIB_A) -Wl,--end-group \
|
||||
$(SDL2_LIBS) $(SDL2TTF_LIBS) -ldl -lm -rdynamic \
|
||||
'-Wl,-rpath,$$ORIGIN'
|
||||
|
||||
@@ -445,15 +450,17 @@ $(BUILD)/editor_harness: tests/editor_harness.c $(SRCS) \
|
||||
$(EIMG_DIR)/include/tb_editor_image.h \
|
||||
$(EFILES_DIR)/include/tb_editor_files.h \
|
||||
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c $(A11Y_DIR)/include/tb_a11y.h \
|
||||
$(EDITOR_SRC)/tb_editor_mcp.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
||||
lib-blueprint ed-modules
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS_DBG) \
|
||||
-I$(ED_DIR)/include -I$(A11Y_DIR)/include -DTB_EDITOR_PRIVATE_API -I$(EW_DIR)/include -I$(EIMG_DIR)/include -I$(EFILES_DIR)/include -I$(GFX_INC) $(CAT_INCS) -I$(BP_DIR)/include \
|
||||
-I$(ED_DIR)/include -I$(A11Y_DIR)/include -I$(MCPS_DIR)/include -DTB_EDITOR_PRIVATE_API -DTB_MCP_SERVER_PRIVATE_API -I$(EW_DIR)/include -I$(EIMG_DIR)/include -I$(EFILES_DIR)/include -I$(GFX_INC) $(CAT_INCS) -I$(BP_DIR)/include \
|
||||
-I$(API_DIR)/include -I$(LIBM_DIR)/include -I$(EN_DIR)/include -I$(TOML_DIR)/include -I$(CV_DIR)/include -I$(B64_DIR)/include -I$(PPM_DIR)/include -I$(SYN_DIR)/include -I$(SB_DIR)/include \
|
||||
$(SRCS) \
|
||||
$(EDITOR_SRC)/tb_editor.c $(EDITOR_SRC)/tb_stage_widget.c \
|
||||
$(EDITOR_SRC)/tb_editor_modules.c \
|
||||
$(GX_DIR)/src/tb_graphics.c $(A11Y_DIR)/src/tb_a11y.c \
|
||||
$(EDITOR_SRC)/tb_editor_mcp.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
||||
$(BP_DIR)/src/blueprint.c $(BP_DIR)/src/serialize.c \
|
||||
$(API_DIR)/src/tb_api.c $(LIBM_DIR)/src/tb_libman.c \
|
||||
$(TOML_LIB_SRCS) $(TOML_DIR)/src/tb_toml.c \
|
||||
@@ -514,10 +521,10 @@ test-environ: $(BUILD)/environ_test ## Roda o teste da environ (ASan/UBSan)
|
||||
# -- Teste da library mcp (servidor de teste tests/mcp_server.py, stdio e HTTP) ---
|
||||
# Sem sanitizers: o CPython embutido nao convive bem com o ASan.
|
||||
ER_DIR := $(LIBDIR)/tinyblocks-errors
|
||||
$(BUILD)/mcp_test: tests/mcp_test.c tests/mcp_server.py $(ER_DIR)/src/tb_errors.c static lib-mcp
|
||||
$(BUILD)/mcp_test: tests/mcp_test.c tests/mcp_server.py $(ER_DIR)/src/tb_errors.c static lib-mcp lib-mcp-server
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS) -g -I$(MC_DIR)/include -I$(PY_DIR)/include -I$(ER_DIR)/include \
|
||||
tests/mcp_test.c $(ER_DIR)/src/tb_errors.c -o $@ \
|
||||
$(CC) $(CFLAGS) -g -I$(MC_DIR)/include -I$(PY_DIR)/include -I$(ER_DIR)/include -I$(MCPS_DIR)/include \
|
||||
tests/mcp_test.c $(ER_DIR)/src/tb_errors.c $(MCPS_A) -o $@ \
|
||||
-Wl,--whole-archive $(LIB_A) -Wl,--no-whole-archive \
|
||||
-L$(MC_DIR)/build -L$(PY_DIR)/build -ltinyblocks-mcp -ltinyblocks-python -lm -rdynamic \
|
||||
'-Wl,-rpath,$(abspath $(MC_DIR)/build)' '-Wl,-rpath,$(abspath $(PY_DIR)/build)'
|
||||
@@ -525,6 +532,16 @@ $(BUILD)/mcp_test: tests/mcp_test.c tests/mcp_server.py $(ER_DIR)/src/tb_errors.
|
||||
test-mcp: $(BUILD)/mcp_test ## Roda o teste do cliente MCP (stdio, HTTP e SSE)
|
||||
./$(BUILD)/mcp_test
|
||||
|
||||
# -- Teste do servidor MCP (as duas eras do protocolo, stdio e HTTP) ---
|
||||
$(BUILD)/mcp_server_test: tests/mcp_server_test.c $(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c \
|
||||
$(MCPS_DIR)/include/tb_mcp_server.h $(MCPS_DIR)/include/tb_mcp_server_internal.h static
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS_DBG) -DTB_MCP_SERVER_PRIVATE_API -I$(MCPS_DIR)/include \
|
||||
$(MCPS_DIR)/src/tb_mcp_server.c $(MCPS_DIR)/src/tb_mcp_http.c tests/mcp_server_test.c -o $@ $(LIB_A) -lm
|
||||
|
||||
test-mcp-server: $(BUILD)/mcp_server_test ## Roda o teste do servidor MCP (ASan/UBSan)
|
||||
./$(BUILD)/mcp_server_test
|
||||
|
||||
# -- Teste da library a11y (arvore acessivel) ---
|
||||
$(BUILD)/a11y_test: tests/a11y_test.c $(A11Y_DIR)/src/tb_a11y.c $(A11Y_DIR)/include/tb_a11y.h static
|
||||
@mkdir -p $(BUILD)
|
||||
|
||||
Reference in new issue
Block a user