Skip to content

Conversation

@yshngg
Copy link
Contributor

@yshngg yshngg commented May 26, 2025

Add support for specifying database type (MongoDB or in-memory database).

Motivation and Context

The README states that MCP Registry supports both MongoDB and in-memory databases, but does not provide the capability to specify which database type to use.

- MongoDB and in-memory database support

This PR addresses this limitation by adding explicit database type configuration through the DATABASE_TYPE environment variable, allowing users to choose between mongodb and memory database types in a standardized way.

How Has This Been Tested?

Yes

$ export MCP_REGISTRY_DATABASE_TYPE="memory"
$ ./scripts/test_endpoints.sh
Testing health endpoint: http://localhost:8080/v0/health
Status Code: 200
Response:
{
  "status": "ok",
  "github_client_id": ""
}
Health check successful
-------------------------------------
Testing servers endpoint: http://localhost:8080/v0/servers
Status Code: 200
Response Summary:
Total registries: 0
servers Names:

Pagination Metadata:
{}

servers Details:
{
  "servers": [],
  "metadata": {}
}
servers request successful
-------------------------------------
Testing ping endpoint: http://localhost:8080/v0/ping
Status Code: 200
Response:
{
  "status": "ok",
  "version": "dev"
}
Ping successful
-------------------------------------
All tests passed successfully!

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Close #63

@yshngg yshngg marked this pull request as ready for review May 26, 2025 13:08
@sridharavinash
Copy link
Contributor

👋🏾 thanks for contributing! Once the merge conflicts are resolved and checks are passing, I'd be happy to merge this in. 🙇🏾

@yshngg yshngg force-pushed the feature/specify-in-memory branch from 530dc30 to 0de1c98 Compare June 4, 2025 01:55
@yshngg
Copy link
Contributor Author

yshngg commented Jun 4, 2025

Hey @sridharavinash , thanks for your reply! Review please.

@sridharavinash sridharavinash requested a review from Copilot June 4, 2025 13:08

This comment was marked as outdated.

@sridharavinash sridharavinash requested a review from Copilot June 4, 2025 13:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Add support for selecting either MongoDB or an in-memory database via a new DATABASE_TYPE configuration.

  • Introduces a DatabaseType enum in Config with a default of "mongodb"
  • Updates main.go to initialize either MongoDB or memory-backed storage based on cfg.DatabaseType
  • Documents the new environment variable in README.md

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/config/config.go Defined DatabaseType constants and added a DatabaseType field
cmd/registry/main.go Switched database initialization based on cfg.DatabaseType
README.md Documented the MCP_REGISTRY_DATABASE_TYPE environment variable
Comments suppressed due to low confidence (2)

README.md:292

  • The README documents MCP_REGISTRY_DATABASE_TYPE, but the code is reading DATABASE_TYPE. Update either the code or the docs so they stay in sync.
| `MCP_REGISTRY_DATABASE_TYPE`         | Database type | `mongodb` |

cmd/registry/main.go:43

  • The new in-memory database branch isn’t covered by any existing tests. Consider adding unit or integration tests to verify behavior when DATABASE_TYPE=memory.
switch cfg.DatabaseType {

Copy link
Contributor

@sridharavinash sridharavinash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this ✨ ! 🙇🏾

@sridharavinash sridharavinash enabled auto-merge (squash) June 4, 2025 13:22
@sridharavinash sridharavinash merged commit 6b22cf0 into modelcontextprotocol:main Jun 4, 2025
7 checks passed
@maorfr
Copy link

maorfr commented Jun 5, 2025

thank you all for this great and timely work ❤️
i've created a follow up item: #129

domdomegg pushed a commit that referenced this pull request Aug 7, 2025
<!-- Provide a brief summary of your changes -->
Add support for specifying database type (MongoDB or in-memory
database).

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
The README states that MCP Registry supports both MongoDB and in-memory
databases, but does not provide the capability to specify which database
type to use.


https://github.com/modelcontextprotocol/registry/blob/5d9171bdccf579398273806a7067cda29e88363c/README.md?plain=1#L19

This PR addresses this limitation by adding explicit database type
configuration through the `DATABASE_TYPE` environment variable, allowing
users to choose between `mongodb` and `memory` database types in a
standardized way.

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Yes

```console
$ export MCP_REGISTRY_DATABASE_TYPE="memory"
$ ./scripts/test_endpoints.sh
Testing health endpoint: http://localhost:8080/v0/health
Status Code: 200
Response:
{
  "status": "ok",
  "github_client_id": ""
}
Health check successful
-------------------------------------
Testing servers endpoint: http://localhost:8080/v0/servers
Status Code: 200
Response Summary:
Total registries: 0
servers Names:

Pagination Metadata:
{}

servers Details:
{
  "servers": [],
  "metadata": {}
}
servers request successful
-------------------------------------
Testing ping endpoint: http://localhost:8080/v0/ping
Status Code: 200
Response:
{
  "status": "ok",
  "version": "dev"
}
Ping successful
-------------------------------------
All tests passed successfully!
```

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
No

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->
Close #63

---------

Co-authored-by: Avinash Sridhar <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

allow running registry with in-memory database

4 participants