v icon indicating copy to clipboard operation
v copied to clipboard

[Feature] Add new standard module: mcp (Model Context Protocol integration)

Open Avey777 opened this issue 1 month ago • 4 comments

Describe the feature

Propose adding a new standard library module mcp to support Model Context Protocol (MCP) — a lightweight protocol for connecting V applications with AI models, tools, or external services.

This module could provide:

Basic MCP client implementation (connect, send, receive)

Type-safe message structures (Request, Response, Error, etc.)

Utilities for integrating with V’s concurrency model (spawn, chan, etc.)

https://github.com/ThinkInAIXYZ/go-mcp

Use Case

import mcp

fn main() {
    mut client := mcp.connect('http://localhost:8000') or { panic(err) }
    response := client.send(.get, '/status', {}) or { panic(err) }
    println(response.body)
}

Proposed Solution

Provide official, standardized way for V programs to integrate with MCP-compatible tools and AI systems.

Encourage interoperability and automation use cases (editor tools, LSP assistants, etc.).

Other Information

No response

Acknowledgements

  • [ ] I may be able to implement this feature request
  • [ ] This feature might incur a breaking change

Version used

V 0.4.12 af62364

Environment details (OS name and version, etc.)

V full version V 0.4.12 c560e7290059aaff6d43005c5bc5d0ed9dab4d9f.af62364
OS linux, Deepin 25
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz
Memory 0.3GB/11.57GB
V executable /home/Jengro/.vmr/versions/v_versions/v_latest/v
V last modified time 2025-11-08 10:57:46
V home dir OK, value: /home/Jengro/.vmr/versions/v_versions/v_latest
VMODULES OK, value: /home/Jengro/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/Jengro
Git version git version 2.50.1
V git status weekly.2025.45-28-gaf62364a
.git/config present true
cc version cc (Deepin 12.3.0-17deepin15) 12.3.0
gcc version gcc (Deepin 12.3.0-17deepin15) 12.3.0
clang version Deepin clang version 17.0.6 (5deepin6)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Debian GLIBC 2.38-6deepin17) 2.38

[!NOTE] You can use the šŸ‘ reaction to increase the issue's priority for developers.

Please note that only the šŸ‘ reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

Avey777 avatar Nov 08 '25 11:11 Avey777

Good idea! This can be a separate library like vsl rather than being in vlib IMHO.

Delta456 avatar Nov 08 '25 14:11 Delta456

Would be great if this code reuse the components from the vlib http, sse and convert https://github.com/nedpals/v-jsonrpc to work with x.json2 whether integrating the sub-components in vlib or vsl.

jorgeluismireles avatar Nov 08 '25 18:11 jorgeluismireles

Perhaps we can create an MCP repository to provide a place for those who want to contribute code

Avey777 avatar Nov 10 '25 06:11 Avey777

https://github.com/vlang/v/issues/25706

Avey777 avatar Nov 16 '25 06:11 Avey777