epugh commented on code in PR #1:
URL: https://github.com/apache/solr-mcp/pull/1#discussion_r2439585031
##########
compose.yaml:
##########
Review Comment:
if you are standing up a single Solr node, then `bin/solr start -c` on 9x
and `bin/solr start` on 10x mean you don't need Zookeeper... Maybe simplify
your setup, unless you are trying to demo fatures of MCP that are related to
interacting with ZooKeeper? "Tell me how Zookeeper is doing" ;-)
##########
build.gradle.kts:
##########
@@ -0,0 +1,80 @@
+import net.ltgt.gradle.errorprone.errorprone
+
+plugins {
+ java
+ alias(libs.plugins.spring.boot)
+ alias(libs.plugins.spring.dependency.management)
+ jacoco
+ alias(libs.plugins.errorprone)
Review Comment:
is there an opportunity to align the coding standards here with what we use
in the main Solr project? I'm thinking errorprone and spotless etc?
##########
init-solr.sh:
##########
@@ -0,0 +1,103 @@
+#!/bin/bash
+set -e
+
+# Ensure mydata directory exists
+mkdir -p /mydata
+
+## Download books.csv if not already present
+#if [ ! -f /mydata/books.csv ]; then
+# wget -O /mydata/books.csv
https://raw.githubusercontent.com/apache/solr/main/solr/example/exampledocs/books.csv
+#fi
+
+# Download films.json if not already present
+if [ ! -f /mydata/films.json ]; then
+ wget -O /mydata/films.json
https://raw.githubusercontent.com/apache/solr/refs/heads/main/solr/example/films/films.json
+fi
+
+
+# Start Solr in background
+/opt/solr/bin/solr start -c -z zoo:2181
+
+# Wait for Solr to be up
+until curl -s http://localhost:8983/solr/ > /dev/null; do
+ echo "Waiting for Solr to start..."
+ sleep 2
+done
+
+# Wait for ZooKeeper to be fully ready for SolrCloud operations
+echo "Waiting for ZooKeeper to be ready for SolrCloud operations..."
+sleep 10
+
+# Wait for cluster state to be ready
+until curl -s
"http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS" | grep -q
'"responseHeader"'; do
+ echo "Waiting for SolrCloud cluster to be ready..."
+ sleep 2
+done
+
+# Create the 'books' collection in SolrCloud mode
+# Check if collection already exists via Collections API
+if ! curl -s "http://localhost:8983/solr/admin/collections?action=LIST" | grep
-q '"books"'; then
+ echo "Creating books collection..."
+ /opt/solr/bin/solr create -c books -n _default || {
+ echo "First attempt failed, retrying collection creation..."
+ sleep 5
+ /opt/solr/bin/solr create -c books -n _default || {
+ echo "Collection creation failed twice, but continuing..."
+ }
+ }
+else
+ echo "Books collection already exists, skipping creation."
+fi
+
+
+# Wait for collection to be ready
+until curl -s "http://localhost:8983/solr/admin/collections?action=LIST" |
grep -q '"books"'; do
+ echo "Waiting for books collection to be ready..."
+ sleep 2
+done
+
+# Create the 'films' collection in SolrCloud mode
+# Check if collection already exists via Collections API
+if ! curl -s "http://localhost:8983/solr/admin/collections?action=LIST" | grep
-q '"films"'; then
+ echo "Creating films collection..."
+ /opt/solr/bin/solr create -c films -n _default || {
Review Comment:
why wouldn't it work?
##########
src/test/java/org/apache/solr/mcp/server/ClientStdio.java:
##########
@@ -0,0 +1,27 @@
+package org.apache.solr.mcp.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.modelcontextprotocol.client.transport.ServerParameters;
+import io.modelcontextprotocol.client.transport.StdioClientTransport;
+import io.modelcontextprotocol.json.jackson.JacksonMcpJsonMapper;
+
+import java.io.File;
+
+// run after project has been built with "./gradlew build -x test and the mcp
server jar is connected to a running solr"
+public class ClientStdio {
+
+ public static void main(String[] args) {
+
+ System.out.println(new File(".").getAbsolutePath());
+
+ var stdioParams = ServerParameters.builder("java")
Review Comment:
how do we make this less brittle?
##########
build.gradle.kts:
##########
@@ -0,0 +1,80 @@
+import net.ltgt.gradle.errorprone.errorprone
+
+plugins {
+ java
+ alias(libs.plugins.spring.boot)
+ alias(libs.plugins.spring.dependency.management)
+ jacoco
+ alias(libs.plugins.errorprone)
+}
+
+group = "org.apache.solr"
Review Comment:
huh.. i expected a name property in here for the artifact?
##########
init-solr.sh:
##########
@@ -0,0 +1,103 @@
+#!/bin/bash
+set -e
+
+# Ensure mydata directory exists
+mkdir -p /mydata
+
+## Download books.csv if not already present
+#if [ ! -f /mydata/books.csv ]; then
+# wget -O /mydata/books.csv
https://raw.githubusercontent.com/apache/solr/main/solr/example/exampledocs/books.csv
+#fi
+
+# Download films.json if not already present
+if [ ! -f /mydata/films.json ]; then
+ wget -O /mydata/films.json
https://raw.githubusercontent.com/apache/solr/refs/heads/main/solr/example/films/films.json
+fi
+
+
+# Start Solr in background
+/opt/solr/bin/solr start -c -z zoo:2181
+
+# Wait for Solr to be up
+until curl -s http://localhost:8983/solr/ > /dev/null; do
+ echo "Waiting for Solr to start..."
+ sleep 2
+done
+
+# Wait for ZooKeeper to be fully ready for SolrCloud operations
+echo "Waiting for ZooKeeper to be ready for SolrCloud operations..."
+sleep 10
+
+# Wait for cluster state to be ready
+until curl -s
"http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS" | grep -q
'"responseHeader"'; do
Review Comment:
Nice pattern! I haven't seen this use of `until` and I like!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]