AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
Add consent-gated Windows MCP host controls (#980)
Amrit Chana349ca444b4fd
diff --git a/CONFIGURATION.md b/CONFIGURATION.mdindex 69260fde..ea3a1ddc 100644--- a/CONFIGURATION.md+++ b/CONFIGURATION.md@@ -95,6 +95,15 @@ Re-run onboarding by deleting `~/.config/last30days/.env`. The mechanical work l---+## MCP host controls++These variables configure the local Go MCP server and are read from its process environment, not from the engine's `.env` files:++| Env var | Default | Accepted values | Behavior and precedence |+|---|---|---|---|+| `LAST30DAYS_PYTHON` | unset | An executable name or path | Selects the Python 3.12+ interpreter used by the MCP server. A caller-supplied `RunOptions.PythonPath` remains the test/caller override; otherwise this variable must resolve to an executable. When it is unset, the server looks up `python3` on `PATH`. An empty or unresolvable value is an error rather than a fallback. |+| `LAST30DAYS_MCP_ALLOW_BROWSER_COOKIES` | unset (deny) | `1`, `true`, `yes`, or `on`, case-insensitive | A recognized truthy value removes the MCP layer's default `--no-browser-cookies` flag. Every other value keeps that denial. This switch grants no consent by itself: browser-cookie access still requires the engine's separately recorded consent and `FROM_BROWSER` configuration. |+## API keys (`.env`)The skill reads keys from a `.env` file. Two locations are supported:diff --git a/changelog.d/+windows-mcp-host-controls.added.md b/changelog.d/+windows-mcp-host-controls.added.mdnew file mode 100644index 00000000..e4a578e8--- /dev/null+++ b/changelog.d/+windows-mcp-host-controls.added.md@@ -0,0 +1 @@+The local MCP server can now use an explicit `LAST30DAYS_PYTHON` interpreter and a default-deny, consent-gated `LAST30DAYS_MCP_ALLOW_BROWSER_COOKIES` switch, enabling reproducible Windows Claude Desktop deployments without weakening the existing cookie-access default.diff --git a/mcp/README.md b/mcp/README.mdindex 2f1d2604..603a059c 100644--- a/mcp/README.md+++ b/mcp/README.md@@ -29,7 +29,9 @@ The output `.mcpb` lands at `build/last30days-pp-mcp-<os>-<arch>.mcpb`. Drag it## Runtime requirements-End users need Python 3.12+ on PATH. The bundle ships the engine source but relies on the host interpreter.+End users need Python 3.12+. The bundle ships the engine source but relies on the host interpreter and does not install Python. By default the server looks up `python3` on `PATH`; set `LAST30DAYS_PYTHON` to an explicit Python executable when the default lookup is not suitable.++MCP research denies browser-cookie access by default by passing `--no-browser-cookies`. Set `LAST30DAYS_MCP_ALLOW_BROWSER_COOKIES` to `1`, `true`, `yes`, or `on` (case-insensitive) to remove that MCP-layer denial. Empty, false, unset, and unrecognized values keep the denial in place. Enabling this variable does not create consent: browser-cookie use still requires the engine's separately recorded consent and configuration.## Versioningdiff --git a/mcp/internal/engine/run.go b/mcp/internal/engine/run.goindex 6afa0984..2b7b865f 100644--- a/mcp/internal/engine/run.go+++ b/mcp/internal/engine/run.go@@ -36,11 +36,15 @@ const DefaultTimeout = 5 * time.Minute// (seconds, integer). Honored by Run when RunOptions.Timeout is zero.const TimeoutEnvOverride = "LAST30DAYS_MCP_TIMEOUT"+// PythonEnvOverride lets operators select the Python 3.12+ executable used+// by the MCP server. When unset, Run preserves the python3 PATH lookup.+const PythonEnvOverride = "LAST30DAYS_PYTHON"+// RunOptions configures one invocation of the embedded Python engine.// PythonPath is exposed so tests can substitute a stub interpreter without// manipulating the process PATH.type RunOptions struct {- PythonPath string // resolved python3 binary; empty means look up DefaultPythonBinary on PATH+ PythonPath string // resolved test/caller override; empty honors PythonEnvOverride, then DefaultPythonBinaryCacheDir string // engine.Ensure result; lib/ here is added to PYTHONPATHArgs []string // arguments after last30days.py (topic, --emit=..., etc.)ExtraEnv []string // appended to os.Environ() for the child process@@ -113,13 +117,30 @@ func Run(ctx context.Context, opts RunOptions) (*RunResult, error) {return res, fmt.Errorf("engine: subprocess failed to start: %w", err)}-// resolvePython returns an absolute path to the interpreter or an error-// naming the install URL. If the caller supplied a path we trust it - tests-// rely on this to inject a stub. Otherwise we look up python3 on PATH.+// resolvePython returns a resolved interpreter path or a clear error. A+// caller-supplied path remains the highest-priority test seam. Otherwise an+// explicitly configured LAST30DAYS_PYTHON must resolve successfully; only+// an absent override falls back to the existing python3 PATH lookup.func resolvePython(override string) (string, error) {if override != "" {return override, nil}+ if configured, ok := os.LookupEnv(PythonEnvOverride); ok {+ if configured == "" {+ return "", fmt.Errorf(+ "engine: %s is set but empty; set it to a Python %s+ executable or unset it to use %s on PATH",+ PythonEnvOverride, MinPythonVersion, DefaultPythonBinary,+ )+ }+ path, err := exec.LookPath(configured)+ if err != nil {+ return "", fmt.Errorf(+ "engine: %s=%q does not resolve to an executable (need Python %s+, install from %s): %w",+ PythonEnvOverride, configured, MinPythonVersion, PythonInstallURL, err,+ )+ }+ return path, nil+ }path, err := exec.LookPath(DefaultPythonBinary)// Go normally rejects relative results with ErrDot. Keep this invariant// even when that protection is disabled with GODEBUG=execerrdot=0.diff --git a/mcp/internal/engine/run_test.go b/mcp/internal/engine/run_test.goindex 521c9f55..97b532e5 100644--- a/mcp/internal/engine/run_test.go+++ b/mcp/internal/engine/run_test.go@@ -6,6 +6,7 @@ import ("os""path/filepath""runtime"+ "strconv""strings""testing""time"@@ -220,10 +221,100 @@ func TestRunTimesOut(t *testing.T) {}}+func TestResolvePythonHonorsEnvOverride(t *testing.T) {+ executable, err := os.Executable()+ if err != nil {+ t.Fatalf("os.Executable: %v", err)+ }+ t.Setenv(PythonEnvOverride, executable)+ t.Setenv("PATH", "")++ got, err := resolvePython("")+ if err != nil {+ t.Fatalf("resolvePython: %v", err)+ }+ gotInfo, err := os.Stat(got)+ if err != nil {+ t.Fatalf("stat resolved path %q: %v", got, err)+ }+ wantInfo, err := os.Stat(executable)+ if err != nil {+ t.Fatalf("stat override path %q: %v", executable, err)+ }+ if !os.SameFile(gotInfo, wantInfo) {+ t.Fatalf("resolvePython = %q, want executable %q", got, executable)+ }+}++func TestResolvePythonRejectsInvalidEnvOverride(t *testing.T) {+ t.Run("missing path", func(t *testing.T) {+ missing := filepath.Join(t.TempDir(), "missing-python")+ t.Setenv(PythonEnvOverride, missing)++ _, err := resolvePython("")+ if err == nil {+ t.Fatal("expected invalid override error")+ }+ if !strings.Contains(err.Error(), PythonEnvOverride) || !strings.Contains(err.Error(), strconv.Quote(missing)) {+ t.Fatalf("error %q does not identify invalid %s path %q", err, PythonEnvOverride, missing)+ }+ })++ t.Run("empty value", func(t *testing.T) {+ t.Setenv(PythonEnvOverride, "")++ _, err := resolvePython("")+ if err == nil {+ t.Fatal("expected empty override error")+ }+ if !strings.Contains(err.Error(), PythonEnvOverride) || !strings.Contains(err.Error(), "set but empty") {+ t.Fatalf("error %q does not clearly identify the empty override", err)+ }+ })+}++func TestResolvePythonDefaultsToPython3Lookup(t *testing.T) {+ dir := t.TempDir()+ name := DefaultPythonBinary+ if runtime.GOOS == "windows" {+ name += ".exe"+ t.Setenv("PATHEXT", ".COM;.EXE;.BAT;.CMD")+ }+ candidate := filepath.Join(dir, name)+ if err := os.WriteFile(candidate, []byte("stub"), 0o755); err != nil {+ t.Fatalf("write default python stub: %v", err)+ }+ t.Setenv(PythonEnvOverride, "temporarily-set-for-cleanup")+ if err := os.Unsetenv(PythonEnvOverride); err != nil {+ t.Fatalf("unset %s: %v", PythonEnvOverride, err)+ }+ t.Setenv("PATH", dir)++ got, err := resolvePython("")+ if err != nil {+ t.Fatalf("resolvePython: %v", err)+ }+ gotInfo, err := os.Stat(got)+ if err != nil {+ t.Fatalf("stat resolved path %q: %v", got, err)+ }+ wantInfo, err := os.Stat(candidate)+ if err != nil {+ t.Fatalf("stat default stub %q: %v", candidate, err)+ }+ if !os.SameFile(gotInfo, wantInfo) {+ t.Fatalf("resolvePython = %q, want python3 lookup result %q", got, candidate)+ }+}+func TestRunMissingPython(t *testing.T) {cache := stageCache(t)// Empty PATH guarantees the lookup fails. PythonPath stays unset so Run// falls through to exec.LookPath.+ t.Setenv(PythonEnvOverride, "temporarily-set-for-cleanup")+ if err := os.Unsetenv(PythonEnvOverride); err != nil {+ t.Fatalf("unset %s: %v", PythonEnvOverride, err)+ }t.Setenv("PATH", "")_, err := Run(context.Background(), RunOptions{CacheDir: cache})diff --git a/mcp/internal/tools/research.go b/mcp/internal/tools/research.goindex d9e81240..d461e887 100644--- a/mcp/internal/tools/research.go+++ b/mcp/internal/tools/research.go@@ -20,6 +20,11 @@ type Config struct {Version string}+// BrowserCookiesEnvOverride is an explicit MCP-layer opt-in. It only removes+// the default-deny CLI flag; the engine still enforces its own recorded+// browser-cookie consent and configuration.+const BrowserCookiesEnvOverride = "LAST30DAYS_MCP_ALLOW_BROWSER_COOKIES"+// Register adds every tool this server exposes to s. The caller supplies a// Config so test harnesses can pin a version without touching globals.func Register(s *server.MCPServer, cfg Config) {@@ -87,13 +92,24 @@ func makeResearchHandler(cfg Config) server.ToolHandlerFunc {}func researchRunArgs(topic, emit string, save bool) []string {- runArgs := []string{topic, "--emit=" + emit, "--no-browser-cookies"}+ runArgs := []string{topic, "--emit=" + emit}+ if !browserCookiesAllowed() {+ runArgs = append(runArgs, "--no-browser-cookies")+ }if save {runArgs = append(runArgs, "--save-dir", mcpSaveDir())}return runArgs}+func browserCookiesAllowed() bool {+ raw := os.Getenv(BrowserCookiesEnvOverride)+ return raw == "1" ||+ strings.EqualFold(raw, "true") ||+ strings.EqualFold(raw, "yes") ||+ strings.EqualFold(raw, "on")+}+func mcpSaveDir() string {saveDir := os.Getenv("LAST30DAYS_MEMORY_DIR")if saveDir == "" {diff --git a/mcp/internal/tools/research_test.go b/mcp/internal/tools/research_test.goindex 2a257b8d..6c44873a 100644--- a/mcp/internal/tools/research_test.go+++ b/mcp/internal/tools/research_test.go@@ -3,6 +3,7 @@ package toolsimport ("context""errors"+ "os""strings""testing"@@ -98,6 +99,10 @@ func TestBoolArgument(t *testing.T) {}func TestResearchRunArgsIncludesNoBrowserCookies(t *testing.T) {+ t.Setenv(BrowserCookiesEnvOverride, "temporarily-set-for-cleanup")+ if err := os.Unsetenv(BrowserCookiesEnvOverride); err != nil {+ t.Fatalf("unset %s: %v", BrowserCookiesEnvOverride, err)+ }args := researchRunArgs("OpenAI", "compact", false)want := []string{"OpenAI", "--emit=compact", "--no-browser-cookies"}if strings.Join(args, "\x00") != strings.Join(want, "\x00") {@@ -105,7 +110,38 @@ func TestResearchRunArgsIncludesNoBrowserCookies(t *testing.T) {}}+func TestResearchRunArgsAllowsBrowserCookiesForTruthyOptIn(t *testing.T) {+ for _, value := range []string{"1", "true", "TRUE", "yes", "YeS", "on", "ON"} {+ t.Run(value, func(t *testing.T) {+ t.Setenv(BrowserCookiesEnvOverride, value)+ args := researchRunArgs("OpenAI", "compact", false)+ want := []string{"OpenAI", "--emit=compact"}+ if strings.Join(args, "\x00") != strings.Join(want, "\x00") {+ t.Fatalf("%s=%q: args = %#v, want %#v", BrowserCookiesEnvOverride, value, args, want)+ }+ })+ }+}++func TestResearchRunArgsDeniesBrowserCookiesForFalseAndUnrecognizedValues(t *testing.T) {+ for _, value := range []string{"", "0", "false", "no", "off", "enabled", " true "} {+ name := value+ if name == "" {+ name = "empty"+ }+ t.Run(name, func(t *testing.T) {+ t.Setenv(BrowserCookiesEnvOverride, value)+ args := researchRunArgs("OpenAI", "compact", false)+ want := []string{"OpenAI", "--emit=compact", "--no-browser-cookies"}+ if strings.Join(args, "\x00") != strings.Join(want, "\x00") {+ t.Fatalf("%s=%q: args = %#v, want %#v", BrowserCookiesEnvOverride, value, args, want)+ }+ })+ }+}+func TestResearchRunArgsSaveUsesSupportedSaveDir(t *testing.T) {+ t.Setenv(BrowserCookiesEnvOverride, "")t.Setenv("LAST30DAYS_MEMORY_DIR", "")args := researchRunArgs("OpenAI", "html", true)got := strings.Join(args, "\x00")@@ -119,6 +155,7 @@ func TestResearchRunArgsSaveUsesSupportedSaveDir(t *testing.T) {}func TestResearchRunArgsSaveUsesMemoryDirEnvOverride(t *testing.T) {+ t.Setenv(BrowserCookiesEnvOverride, "")t.Setenv("LAST30DAYS_MEMORY_DIR", "/tmp/last30days-reports")args := researchRunArgs("OpenAI", "html", true)want := []string{"OpenAI", "--emit=html", "--no-browser-cookies", "--save-dir", "/tmp/last30days-reports"}