Skip to content

Conversation

@AlmazErmilov
Copy link

Halla folkens!

Hope you all have en riktig god sommer! 🌞

I'm finally reviving one of my favourite old pet projects that will culminate in an ADIPEC paper this autumn 2025,
for the petrophysical part I've decided to build an MCP server on top of welly, a library I’ve used and loved before,
and an MCP server feels like the natural next step for welly

I'm contributing only the 5 tools for welly MCP, would love to make it bigger and contribute more,
but before proceeding I would love to hear your feedback on the architecture and overall approach,
contact me for a bigger picture if needed

my background is degrees and experiences in Computer Science and Geophysics,
(so both domain and tech expertise are in place)

admire your work 🫡,
more formal PR message below,

Almaz
almaz.ermilov@gmail.com
almaz.ermilov@uit.no


Add Model Context Protocol (MCP) server for AI-assisted petrophysical analysis

This PR introduces a new welly.mcp module that explores welly's petrophysical analysis capabilities to AI assistants through the Model Context Protocol (MCP).

Key features

  • 5 Core MCP Tools: load_las_well, get_curve_stats, plot_well_log, get_well_info, list_curves
  • Session management: In-memory well storage for multi-step workflows
  • Testing: 11 unit tests covering all functionality
  • Production ready: Compatible with Cursor IDE and other MCP clients

Technical implementation

  • Integration in welly/mcp/ without modifying core welly code
  • Uses welly's existing ALIAS system for curve name standardization
  • Leverages welly's plot functions with legend support
  • Async/await architecture, error handling

Use cases

  • Natural language well log analysis through AI assistants
  • Automated statistical analysis and visualization workflows
  • Educational tools for petrophysics training
  • Quick data exploration and QC processes

Files added / file tree

welly/mcp/
├── __init__.py     # Module exports
├── main.py         # CLI entry point
├── mcp_server.py   # MCP protocol implementation
├── tools.py        # Core analysis tools
├── session.py      # Session management
├── README.md       # Documentation
└── tests/          # Test suite

Testing

All newly created tests pass (11/11). Ready for integration.

A couple of examples of use inside Cursor IDE below (Gemini 2.5 Pro as LLM used)

Fig 1 – initial well log analysis
Initial well log analysis


Fig 2 – plot visualisation
Zoomed interval

please check welly/mcp/README.md for a deeper dive

- Add mcp>=1.0.0 as optional dependency in pyproject.toml
- Enables installation with: pip install welly[mcp]
- Prepares infrastructure for Model Context Protocol server
Introduces MCP server infrastructure for petrophysical analysis,
enabling integration with AI assistants for well log processing.

- Add core MCP server with standard protocol implementation
- Implement session management for stateful well operations
- Create tool suite for LAS file loading and analysis
- Support base64 image encoding for plot visualization
- Include requirements and entry point configuration
- Add unit tests for MCP server functionality
- Include pytest configuration for test execution
- Create README with installation and usage instructions
- Document available tools and integration patterns
Add Almaz Ermilov (UiT University of Tromsø, Norway) for
MCP server implementation contribution.
- Replace well.plot() with plot_well() function for proper legend support
- Add striplog legend system with standard curve scaling
- Implement curve type recognition using welly ALIAS dictionary
- Fix JSON serialization error by converting numpy bool_ to Python bool
- Add curve plotting with appropriate colors and ranges
- Update docstrings with usage examples and parameter details
- Update tool descriptions with practical examples
- Revise parameter descriptions for clarity
- Modify filesystem path terminology
- Update docstring language
- Update curve plotting parameters to align with quite common industry standards
- Introduce additional curve types and corresponding colors
- Implement default line styles for recognized curves
@AlmazErmilov
Copy link
Author

Hei @kwinkunks! let me know if you want to make it bigger together 🫡

@annsergeevva
Copy link

👍👍👍

@Twirax
Copy link

Twirax commented Jul 24, 2025

Very like your staff @AlmazErmilov

@kwinkunks
Copy link
Member

Interesting project, thanks for the contribution.

I have not thghout a lot about how MCPs are likely to be consumed / combined etc. My own feeling is that this component should perhaps be its own project, rather than being bundled with the library. What do you think?

Interested in what others think too.

@AlmazErmilov
Copy link
Author

My own feeling is that this component should perhaps be its own project, rather than being bundled with the library. What do you think?

Fair enough, agree,
I'm fine with either option,
would be nice to discuss further and agree on how to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants