-
Notifications
You must be signed in to change notification settings - Fork 45
Update documentation and contributing guidelines #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
032f6e4
update error handling docs, usage examples,
keremgocen e0e2360
Merge branch 'main' into keremgocen/add-documentation
keremgocen a806fb7
Merge branch 'main' into keremgocen/add-documentation
keremgocen 70b73e2
update docs
keremgocen 7cc52ea
update readme to be more concise
keremgocen 85d0fdd
update contributing guidelines
keremgocen d05b27b
copilot review
keremgocen 22e1e03
contributions on the neo4j-mcp documentation
MacondoExpress 910160c
update the README.md page
MacondoExpress e5ad32d
Merge pull request #35 from neo4j/revision-documentation-pr
MacondoExpress f15ffbd
Update README.md
MacondoExpress 16a328d
update README.md.
MacondoExpress 2555ed2
Merge branch 'main' into keremgocen/add-documentation
MacondoExpress a01aea4
Update README.md
keremgocen 2933b28
Update CONTRIBUTING.md
keremgocen f6f7e35
move env variables up, before the run commands
keremgocen 9c44cbd
add repo root comment
keremgocen cc7c05f
update file name
keremgocen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Contributing to Neo4j MCP | ||
|
|
||
| Thank you for your interest in contributing to the Neo4j MCP server! This document provides guidelines and information for contributors. | ||
|
|
||
| If you're an external contributor you must sign the [https://neo4j.com/developer/contributing-code/#sign-cla](https://neo4j.com/developer/contributing-code/#sign-cla) | ||
|
|
||
| ## Code of Conduct | ||
|
|
||
| Please read and follow these guidelines to ensure a welcoming environment for everyone. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Go 1.25+ (see `go.mod`) | ||
| - A Neo4j instance with APOC plugin installed. | ||
|
|
||
| ## Clone the repository (forks are currently disabled) | ||
|
|
||
| ```bash | ||
| git clone git@github.com:neo4j/mcp.git && cd mcp | ||
| ``` | ||
|
|
||
| ## Install Dependencies | ||
|
|
||
| ```bash | ||
| # Install Go dependencies | ||
| go mod download | ||
|
|
||
| # Install mock generator (only if you will change interfaces) | ||
| go install go.uber.org/mock/mockgen@latest | ||
| export PATH="$PATH:$(go env GOPATH)/bin" | ||
| ``` | ||
|
|
||
| ## Build / Test / Run | ||
|
|
||
| ```bash | ||
| # Tests (coverage) | ||
| go test ./... -cover | ||
|
|
||
| # Verbose / single package | ||
| go test ./internal/tools -v | ||
|
|
||
| # Build binary | ||
| go build -C cmd/neo4j-mcp -o ../../bin/ | ||
|
|
||
| # Run from source | ||
| go run ./cmd/neo4j-mcp | ||
|
keremgocen marked this conversation as resolved.
|
||
|
|
||
| # Optional: install | ||
| go install -C cmd/neo4j-mcp | ||
|
keremgocen marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| For local testing, set these environment variables: | ||
|
|
||
| ```bash | ||
| export NEO4J_URI="bolt://localhost:7687" | ||
| export NEO4J_USERNAME="neo4j" | ||
| export NEO4J_PASSWORD="password" | ||
| export NEO4J_DATABASE="neo4j" | ||
| ``` | ||
|
keremgocen marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Mocks | ||
|
|
||
| We rely on interface-based dependency injection plus generated mocks (gomock) so tests run without a live Neo4j instance. | ||
|
|
||
| Regenerate mocks ONLY after changing interfaces (e.g. `internal/database/interfaces.go`): | ||
|
|
||
| ```bash | ||
| cd internal/database && go generate | ||
| ``` | ||
|
|
||
| Minimal gomock example: | ||
|
|
||
| ```go | ||
| func TestMyFunction(t *testing.T) { | ||
| ctrl := gomock.NewController(t) | ||
| defer ctrl.Finish() | ||
|
|
||
| mockDB := mocks.NewMockDatabaseService(ctrl) | ||
| mockDB.EXPECT(). | ||
| ExecuteReadQuery(gomock.Any(), "MATCH (n) RETURN n", gomock.Nil(), "neo4j"). | ||
| Return([]*neo4j.Record{}, nil) | ||
|
|
||
| // Use mockDB in your test ... | ||
| } | ||
| ``` | ||
|
|
||
| See `internal/tools/get_schema_handler_gomock_test.go` for a fuller pattern. | ||
|
keremgocen marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Testing using the @modelcontextprotocol/inspector: | ||
|
|
||
| The Neo4j MCP capabilities can be tested using the `@modelcontextprotocol/inspector`: | ||
|
|
||
| ```bash | ||
| npx @modelcontextprotocol/inspector go run ./cmd/neo4j-mcp | ||
| ``` | ||
|
|
||
| ## Adding New MCP Tools | ||
|
|
||
| 1. **Define tool specification** in `internal/tools/`: | ||
|
keremgocen marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```go | ||
| func NewMyToolSpec() mcp.Tool { | ||
| return mcp.NewTool("my-tool", | ||
| mcp.WithDescription("Tool description"), | ||
| mcp.WithInputSchema[MyToolInput](), | ||
| ) | ||
| } | ||
| ``` | ||
|
|
||
| 2. **Implement tool handler**: | ||
|
|
||
| ```go | ||
| func NewMyToolHandler(deps *ToolDependencies) mcp.ToolHandler { | ||
| return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||
| // Implementation | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. **Register in tool_register.go**: | ||
|
|
||
| ```go | ||
| { | ||
| Tool: NewMyToolSpec(), | ||
| Handler: NewMyToolHandler(deps), | ||
| }, | ||
| ``` | ||
|
|
||
| 4. **Write tests** with mocked dependencies | ||
|
|
||
| ### Database Interface Extensions | ||
|
|
||
| When adding new database operations: | ||
|
|
||
| 1. **Extend the interface** in `internal/database/interfaces.go` | ||
| 2. **Implement in service** in `internal/database/service.go` | ||
| 3. **Regenerate mocks**: `cd internal/database && go generate` | ||
| 4. **Update tests** to use new mock methods | ||
|
|
||
| ### Quick Fixes | ||
|
|
||
| Mock generation fails → ensure `mockgen` on PATH. | ||
| Tests failing unexpectedly → regenerate mocks, verify env vars, rerun full test suite. | ||
| Dependency/build issues → `go mod tidy`. | ||
|
|
||
| ### Getting Help | ||
|
|
||
| - Check existing [GitHub Issues](https://github.com/neo4j/mcp/issues) | ||
| - Ask questions in pull request discussions | ||
| - Reach out to maintainers for complex architectural questions | ||
|
|
||
| Thank you for contributing to making Neo4j MCP better! | ||
|
keremgocen marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.