← Back to Documentation

Cure LSP and MCP Update - November 26, 2025

Summary

Updated both the Cure Language Server Protocol (LSP) and Model Context Protocol (MCP) servers to ensure compatibility with the latest compiler API changes. Both servers now compile successfully and are ready for use.

Changes Made

1. MCP Server API Updates (mcp/cure_mcp_server.erl)

Type Checker API

Code Generator API

Record Definitions

2. LSP Server Status

The LSP server (src/lsp/cure_lsp_server.erl) was already using the correct APIs:
- ✅ Uses cure_typechecker:check_module/2 and builtin_env/0
- ✅ Uses correct lexer and parser APIs
- ✅ Includes proper record definitions via cure_ast.hrl
- ✅ No changes required

3. Compilation Results

Both servers compile successfully with only minor warnings about unused variables:

MCP Warnings

LSP Warnings

Testing

Build Verification

make all  # ✅ Successful with warnings

Executable Tests

./cure-lsp --help   # ✅ Working
./cure-mcp --help   # ✅ Working

API Compatibility

Current API Reference

Type Checker

%% Check entire program
Result = cure_typechecker:check_program(AST),
case Result#typecheck_result.success of
    true -> ok;
    false -> Errors = Result#typecheck_result.errors
end.

%% Check module
{ok, NewEnv, Result} = cure_typechecker:check_module(ModuleAST, Env),
{error, Error} = cure_typechecker:check_module(BadModule, Env).

%% Get builtin environment
Env = cure_typechecker:builtin_env().

Code Generator

%% Compile program
{ok, Modules} = cure_codegen:compile_program(AST),

%% Compile with options
Options = [{debug_info, true}, {optimize, 2}],
{ok, Modules} = cure_codegen:compile_program(AST, Options),

%% Write BEAM file
lists:foreach(fun(Mod) ->
    ModName = element(2, Mod),
    BeamFile = atom_to_list(ModName) ++ ".beam",
    cure_codegen:write_beam_module(Mod, BeamFile)
end, Modules).

Lexer & Parser

%% Tokenize source code
{ok, Tokens} = cure_lexer:tokenize(SourceBinary),
{error, {Reason, Line, Col}} = cure_lexer:tokenize(BadSource),

%% Parse tokens to AST
{ok, AST} = cure_parser:parse(Tokens),
{error, ParseError} = cure_parser:parse(BadTokens).

Files Modified

  1. mcp/cure_mcp_server.erl
    - Updated compile_cure_code/3 to use check_program and compile_program
    - Updated type_check_cure_code/1 to use check_program
    - Added typecheck_result record definition
    - Fixed BEAM file generation logic
    - Added ensure_binary/1 helper to handle JSON string/binary conversion
    - Fixed format_success/2 and format_error/2 to use iolist_to_binary
    - Fixed summarize_ast/1 to return binary instead of string
    - Replaced Unicode characters with ASCII for better compatibility

Files Verified (No Changes Needed)

  1. src/lsp/cure_lsp_server.erl - Already using correct APIs
  2. src/lsp/cure_lsp_code_actions.erl - Compatible with current AST
  3. src/lsp/cure_lsp_diagnostics.erl - Compatible with current AST
  4. src/lsp/cure_lsp_performance.erl - Compatible with current AST
  5. src/lsp/cure_lsp_smt.erl - Compatible with current AST
  6. src/lsp/cure_lsp_type_holes.erl - Compatible with current AST

Integration Status

Compiler Components

LSP Features

MCP Tools

Recommendations

  1. For Users: Both LSP and MCP servers are ready to use with editors/IDEs and AI assistants
  2. For Developers: The APIs are now consistent across the compiler pipeline
  3. Future Updates: Monitor these functions for any signature changes:
    - cure_typechecker:check_program/1,2
    - cure_codegen:compile_program/1,2
    - cure_codegen:write_beam_module/2

Next Steps

  1. Testing: Run integration tests with actual Cure code
  2. Documentation: Update user-facing LSP/MCP setup guides if needed
  3. Monitoring: Watch for any API changes in future compiler updates

Version Information